WIP traducciones: respetar la dirección del texto

This commit is contained in:
f 2020-05-23 15:42:12 -03:00
parent b41696c15c
commit 16fe1e33c0
26 changed files with 78 additions and 40 deletions

View file

@ -69,6 +69,13 @@ body {
color: var(--foreground); color: var(--foreground);
} }
* {
.rtl,
&[dir=rtl] {
text-align: right;
}
}
a { a {
color: var(--color); color: var(--color);
@ -123,11 +130,6 @@ ol.breadcrumb {
background-color: $magenta; background-color: $magenta;
} }
.rtl {
direction: rtl;
text-align: right;
}
.btn-text { .btn-text {
background-color: transparent; background-color: transparent;
border: none; border: none;

View file

@ -33,6 +33,7 @@ class PostsController < ApplicationController
@site = find_site @site = find_site
@post = @site.posts(lang: locale).find params[:id] @post = @site.posts(lang: locale).find params[:id]
authorize @post authorize @post
@locale = locale
fresh_when @post fresh_when @post
end end
@ -41,6 +42,7 @@ class PostsController < ApplicationController
authorize Post authorize Post
@site = find_site @site = find_site
@post = @site.posts.build(lang: locale, layout: params[:layout]) @post = @site.posts.build(lang: locale, layout: params[:layout])
@locale = locale
end end
def create def create
@ -64,6 +66,8 @@ class PostsController < ApplicationController
@post = @site.posts(lang: locale).find params[:id] @post = @site.posts(lang: locale).find params[:id]
authorize @post authorize @post
@locale = locale
end end
def update def update

View file

@ -51,6 +51,10 @@ MetadataTemplate = Struct.new(:site, :document, :name, :label, :type,
name name
end end
def to_s
value.to_s
end
# Decide si el metadato se coloca en el front_matter o no # Decide si el metadato se coloca en el front_matter o no
def front_matter? def front_matter?
true true

View file

@ -5,4 +5,4 @@
- metadata.value.each do |v| - metadata.value.each do |v|
%span.badge.badge-primary= v %span.badge.badge-primary= v
- else - else
%span.badge.badge-primary= metadata.value %span.badge.badge-primary{ lang: locale, dir: dir }= metadata.value

View file

@ -1,3 +1,3 @@
%tr{ id: attribute } %tr{ id: attribute }
%th= post_label_t(attribute, post: post) %th= post_label_t(attribute, post: post)
%td= t "_#{post.send(attribute).value}" %td{ lang: locale, dir: dir }= t "_#{post.send(attribute).value}"

View file

@ -1,3 +1,3 @@
%tr{ id: attribute } %tr{ id: attribute }
%th= post_label_t(attribute, post: post) %th= post_label_t(attribute, post: post)
%td{ style: "background-color: #{metadata.value}" } = metadata.value %td{ lang: locale, dir: dir, style: "background-color: #{metadata.value}" } = metadata.value

View file

@ -1,3 +1,3 @@
%tr{ id: attribute } %tr{ id: attribute }
%th= post_label_t(attribute, post: post) %th= post_label_t(attribute, post: post)
%td= metadata.value %td{ lang: locale, dir: dir }= metadata.value

View file

@ -1,3 +1,3 @@
%tr{ id: attribute } %tr{ id: attribute }
%th= post_label_t(attribute, post: post) %th= post_label_t(attribute, post: post)
%td= l metadata.value.to_date %td{ dir: dir, lang: locale }= l metadata.value.to_date

View file

@ -1,3 +1,3 @@
%tr{ id: attribute } %tr{ id: attribute }
%th= post_label_t(attribute, post: post) %th= post_label_t(attribute, post: post)
%td= l metadata.value.to_date %td{ lang: locale, dir: dir }= l metadata.value.to_date

View file

@ -1,4 +1,4 @@
%tr{ id: attribute } %tr{ id: attribute }
%th= post_label_t(attribute, post: post) %th= post_label_t(attribute, post: post)
%td %td{ dir: dir, lang: locale }
%a{ href: "mailto:#{metadata.value}" }= metadata.value %a{ href: "mailto:#{metadata.value}" }= metadata.value

View file

@ -3,4 +3,4 @@
%td %td
- if metadata.value['path'].present? - if metadata.value['path'].present?
= link_to t('.download'), url_for(metadata.static_file) = link_to t('.download'), url_for(metadata.static_file)
%p= metadata.value['description'] %p{ dir: dir, lang: locale }= metadata.value['description']

View file

@ -6,4 +6,4 @@
= image_tag url_for(metadata.static_file), = image_tag url_for(metadata.static_file),
alt: metadata.value['description'], alt: metadata.value['description'],
class: 'img-fluid' class: 'img-fluid'
%figcaption= metadata.value['description'] %figcaption{ dir: dir, lang: locale }= metadata.value['description']

View file

@ -1,3 +1,3 @@
%tr{ id: attribute } %tr{ id: attribute }
%th= post_label_t(attribute, post: post) %th= post_label_t(attribute, post: post)
%td= t(metadata.value) %td{ lang: locale, dir: dir }= t(metadata.value)

View file

@ -0,0 +1,9 @@
%tr{ id: attribute }
%th= post_label_t(attribute, post: post)
%td
%ul
- metadata.value.each do |uuid|
- p = site.docs.find(uuid, uuid: true)
%li{ dir: t("locales.#{p.lang.value}.dir"), lang: p.lang.value }
= link_to p.title.value,
site_post_path(site, p.id, locale: p.lang.value)

View file

@ -1,3 +1,3 @@
%tr{ id: attribute } %tr{ id: attribute }
%th= post_label_t(attribute, post: post) %th= post_label_t(attribute, post: post)
%td= metadata.value %td{ dir: dir, lang: locale }= metadata.value

View file

@ -1,3 +1,3 @@
%tr{ id: attribute } %tr{ id: attribute }
%th= post_label_t(attribute, post: post) %th= post_label_t(attribute, post: post)
%td= metadata.value %td{ dir: dir, lang: locale }= metadata.value

View file

@ -2,4 +2,4 @@
%th= post_label_t(attribute, post: post) %th= post_label_t(attribute, post: post)
%td %td
- metadata.value.each do |v| - metadata.value.each do |v|
%span.badge.badge-primary= metadata.values.key v %span.badge.badge-primary{ dir: dir, lang: locale }= metadata.values.key v

View file

@ -1,7 +1,7 @@
%tr{ id: attribute } %tr{ id: attribute }
%th= post_label_t(attribute, post: post) %th= post_label_t(attribute, post: post)
%td %td
%ul %ul{ dir: dir, lang: locale }
- metadata.value.each do |v| - metadata.value.each do |v|
- p = site.posts(lang: post.lang.value).find(v, uuid: true) - p = site.posts(lang: post.lang.value).find(v, uuid: true)
-# -#

View file

@ -1,3 +1,3 @@
%tr{ id: attribute } %tr{ id: attribute }
%th= post_label_t(attribute, post: post) %th= post_label_t(attribute, post: post)
%td= metadata.value %td{ dir: dir, lang: locale }= metadata.value

View file

@ -1,3 +1,3 @@
%tr{ id: attribute } %tr{ id: attribute }
%th= post_label_t(attribute, post: post) %th= post_label_t(attribute, post: post)
%td= metadata.value %td{ dir: dir, lang: locale }= metadata.value

View file

@ -1,3 +1,3 @@
%tr{ id: attribute } %tr{ id: attribute }
%th= post_label_t(attribute, post: post) %th= post_label_t(attribute, post: post)
%td= link_to metadata.value %td{ dir: dir, lang: locale }= link_to metadata.value

View file

@ -8,18 +8,19 @@
- site.locales.each do |locale| - site.locales.each do |locale|
-# Ignorar el idioma actual -# Ignorar el idioma actual
- next if post.lang.value == locale - next if post.lang.value == locale
- locale_t = t("locales.#{locale}.name")
- values = metadata.value.select do |x| - values = metadata.value.select do |x|
- metadata.values[locale.to_sym].values.include? x - metadata.values[locale.to_sym].values.include? x
.form-group .form-group
= label_tag "post_#{attribute}_#{locale}", t(locale) = label_tag "post_#{attribute}_#{locale}", locale_t
.mapable{ data: { values: values.to_json, .mapable{ data: { values: values.to_json,
'default-values': metadata.values[locale.to_sym].to_json, 'default-values': metadata.values[locale.to_sym].to_json,
name: "post[#{attribute}][]", name: "post[#{attribute}][]",
list: id_for_datalist(attribute, locale), list: id_for_datalist(attribute, locale),
button: t('posts.attributes.add'), button: t('posts.attributes.add'),
remove: 'false', legend: t(locale), remove: 'false', legend: locale_t,
described: id_for_help(attribute, locale) } } described: id_for_help(attribute, locale) } }
= text_field(*field_name_for('post', attribute, '[]'), = text_field(*field_name_for('post', attribute, '[]'),

View file

@ -38,10 +38,11 @@
idiomas idiomas
.locales .locales
- @site.locales.each do |locale| - @site.locales.each do |locale|
= link_to t(locale), site_posts_path(@site, locale: locale), = link_to t("locales.#{locale}.name"), site_posts_path(@site, locale: locale),
class: "mr-2 mt-2 mb-2#{locale == @locale ? 'active font-weight-bold' : ''}" class: "mr-2 mt-2 mb-2#{locale == @locale ? 'active font-weight-bold' : ''}"
%table.table.table-condensed.table-draggable %table.table.table-condensed.table-draggable
%tbody %tbody
- dir = t("locales.#{@locale}.dir")
- @posts.each_with_index do |post, i| - @posts.each_with_index do |post, i|
-# -#
saltearse el post a menos que esté en la categoría por saltearse el post a menos que esté en la categoría por
@ -63,13 +64,13 @@
-# Orden más alto es mayor prioridad -# Orden más alto es mayor prioridad
= hidden_field 'post[reorder]', post.uuid.value, = hidden_field 'post[reorder]', post.uuid.value,
value: @posts.length - i, class: 'reorder' value: @posts.length - i, class: 'reorder'
%td %td{ class: dir }
%small %small
= link_to @site.i18n.dig('layouts', post.layout.name.to_s) || post.layout.name.to_s.humanize, = link_to @site.i18n.dig('layouts', post.layout.name.to_s) || post.layout.name.to_s.humanize,
site_posts_path(@site, layout: post.layout.name) site_posts_path(@site, layout: post.layout.name)
%br/ %br/
= link_to post.title.value, = link_to site_post_path(@site, post.id) do
site_post_path(@site, post.id) %span{ lang: post.lang.value, dir: dir }= post.title.value
- if post.attributes.include? :draft - if post.attributes.include? :draft
- if post.draft.value - if post.draft.value
%span.badge.badge-primary %span.badge.badge-primary
@ -79,7 +80,8 @@
%br %br
%small %small
- post.categories.value.each do |c| - post.categories.value.each do |c|
= link_to c, site_posts_path(@site, category: c) = link_to site_posts_path(@site, category: c) do
%span{ lang: post.lang.value, dir: dir }= c
%td %td
= post.date.value.strftime('%F') = post.date.value.strftime('%F')

View file

@ -4,6 +4,7 @@
link_to(t('posts.index'), site_posts_path(@site)), link_to(t('posts.index'), site_posts_path(@site)),
@post.title.value] @post.title.value]
- dir = t("locales.#{@locale}.dir")
.row .row
.col .col
%article.content %article.content
@ -27,11 +28,12 @@
post: @post, attribute: attr, post: @post, attribute: attr,
metadata: metadata, metadata: metadata,
site: @site, site: @site,
tags: all_html_tags) tags: all_html_tags,
dir: dir)
-# Mostrar todo lo que no va en el front_matter (el contenido) -# Mostrar todo lo que no va en el front_matter (el contenido)
- @post.attributes.each do |attr| - @post.attributes.each do |attr|
- next if @post.send(attr).front_matter? - next if @post.send(attr).front_matter?
%section{ id: attr } %section{ id: attr, dir: dir }
= @post.send(attr).value.html_safe = @post.send(attr).to_s.html_safe

View file

@ -1,4 +1,15 @@
en: en:
dir: ltr
locales:
es:
name: Castillian Spanish
dir: ltr
en:
name: English
dir: ltr
ar:
name: Arabic
dir: rtl
login: login:
email: E-mail address email: E-mail address
password: Password password: Password
@ -7,7 +18,6 @@ en:
sr-help: "After this form you'll find links to recover your account and other actions." sr-help: "After this form you'll find links to recover your account and other actions."
_true: Yes _true: Yes
_false: No _false: No
dir: ltr
svg: svg:
sutty: sutty:
title: Sutty title: Sutty
@ -33,9 +43,6 @@ en:
layout_missing: 'Needs an instance of Layout' layout_missing: 'Needs an instance of Layout'
document_missing: 'Needs an instance of Jekyll::Document' document_missing: 'Needs an instance of Jekyll::Document'
no_method: '%{method} not allowed' no_method: '%{method} not allowed'
es: Castillian Spanish
en: English
ar: Arabic
seconds: '%{seconds} seconds' seconds: '%{seconds} seconds'
contact_mailer: contact_mailer:
subject: '[%site] Contact form' subject: '[%site] Contact form'

View file

@ -1,4 +1,15 @@
es: es:
dir: ltr
locales:
es:
name: Castellano
dir: ltr
en:
name: Inglés
dir: ltr
ar:
name: Árabe
dir: rtl
login: login:
email: Correo electrónico email: Correo electrónico
password: Contraseña password: Contraseña
@ -7,7 +18,6 @@ es:
sr-help: 'Después del formulario encontrarás vínculos para recuperar tu cuenta, entre otras acciones.' sr-help: 'Después del formulario encontrarás vínculos para recuperar tu cuenta, entre otras acciones.'
_true: _true:
_false: No _false: No
dir: ltr
svg: svg:
sutty: sutty:
title: Sutty title: Sutty
@ -35,9 +45,6 @@ es:
layout_missing: 'Necesita una instancia de Layout' layout_missing: 'Necesita una instancia de Layout'
document_missing: 'Necesita una instancia de Jekyll::Document' document_missing: 'Necesita una instancia de Jekyll::Document'
no_method: '%{method} no está permitido' no_method: '%{method} no está permitido'
es: Castellano
en: Inglés
ar: Árabe
seconds: '%{seconds} segundos' seconds: '%{seconds} segundos'
contact_mailer: contact_mailer:
subject: '[%{site}] Formulario de contacto' subject: '[%{site}] Formulario de contacto'