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);
}
* {
.rtl,
&[dir=rtl] {
text-align: right;
}
}
a {
color: var(--color);
@ -123,11 +130,6 @@ ol.breadcrumb {
background-color: $magenta;
}
.rtl {
direction: rtl;
text-align: right;
}
.btn-text {
background-color: transparent;
border: none;

View file

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

View file

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

View file

@ -5,4 +5,4 @@
- metadata.value.each do |v|
%span.badge.badge-primary= v
- 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 }
%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 }
%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 }
%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 }
%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 }
%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 }
%th= post_label_t(attribute, post: post)
%td
%td{ dir: dir, lang: locale }
%a{ href: "mailto:#{metadata.value}" }= metadata.value

View file

@ -3,4 +3,4 @@
%td
- if metadata.value['path'].present?
= 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),
alt: metadata.value['description'],
class: 'img-fluid'
%figcaption= metadata.value['description']
%figcaption{ dir: dir, lang: locale }= metadata.value['description']

View file

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

View file

@ -1,3 +1,3 @@
%tr{ id: attribute }
%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 }
%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 }
%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|
-# Ignorar el idioma actual
- next if post.lang.value == locale
- locale_t = t("locales.#{locale}.name")
- values = metadata.value.select do |x|
- metadata.values[locale.to_sym].values.include? x
.form-group
= label_tag "post_#{attribute}_#{locale}", t(locale)
= label_tag "post_#{attribute}_#{locale}", locale_t
.mapable{ data: { values: values.to_json,
'default-values': metadata.values[locale.to_sym].to_json,
name: "post[#{attribute}][]",
list: id_for_datalist(attribute, locale),
button: t('posts.attributes.add'),
remove: 'false', legend: t(locale),
remove: 'false', legend: locale_t,
described: id_for_help(attribute, locale) } }
= text_field(*field_name_for('post', attribute, '[]'),

View file

@ -38,10 +38,11 @@
idiomas
.locales
- @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' : ''}"
%table.table.table-condensed.table-draggable
%tbody
- dir = t("locales.#{@locale}.dir")
- @posts.each_with_index do |post, i|
-#
saltearse el post a menos que esté en la categoría por
@ -63,13 +64,13 @@
-# Orden más alto es mayor prioridad
= hidden_field 'post[reorder]', post.uuid.value,
value: @posts.length - i, class: 'reorder'
%td
%td{ class: dir }
%small
= 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)
%br/
= link_to post.title.value,
site_post_path(@site, post.id)
= link_to site_post_path(@site, post.id) do
%span{ lang: post.lang.value, dir: dir }= post.title.value
- if post.attributes.include? :draft
- if post.draft.value
%span.badge.badge-primary
@ -79,7 +80,8 @@
%br
%small
- 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
= post.date.value.strftime('%F')

View file

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

View file

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

View file

@ -1,4 +1,15 @@
es:
dir: ltr
locales:
es:
name: Castellano
dir: ltr
en:
name: Inglés
dir: ltr
ar:
name: Árabe
dir: rtl
login:
email: Correo electrónico
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.'
_true:
_false: No
dir: ltr
svg:
sutty:
title: Sutty
@ -35,9 +45,6 @@ es:
layout_missing: 'Necesita una instancia de Layout'
document_missing: 'Necesita una instancia de Jekyll::Document'
no_method: '%{method} no está permitido'
es: Castellano
en: Inglés
ar: Árabe
seconds: '%{seconds} segundos'
contact_mailer:
subject: '[%{site}] Formulario de contacto'