Update documentation to customize translations

This commit is contained in:
Javi Martín
2024-09-02 14:29:34 +02:00
parent 3a01e171b8
commit 136edb97e9
6 changed files with 32 additions and 33 deletions

View File

@@ -29,7 +29,7 @@
* [Customization](customization/customization.md)
* [Introduction](customization/introduction.md)
* [Translations and Texts](customization/translations.md)
* [Translations and texts](customization/translations.md)
* [Images](customization/images.md)
* [Styles with CSS](customization/css.md)
* [JavaScript](customization/javascript.md)

View File

@@ -1,7 +1,7 @@
# Customization
* [Introduction](introduction.md)
* [Translations and Texts](translations.md)
* [Translations and texts](translations.md)
* [Images](images.md)
* [Styles with CSS](css.md)
* [JavaScript](javascript.md)

View File

@@ -1,38 +1,38 @@
# Translations and Texts
# Customizing translations and texts
## Translations
Currently, Consul Democracy is totally or partially translated to multiple languages. You can find the translations at the [Crowdin project](https://translate.consuldemocracy.org/).
Please [join the translators](https://crwd.in/consul) to help us complete existing ones, or contact us through [Consul Democracy's gitter](https://gitter.im/consul/consul) to become a proofreader and validate translators' contributions.
Please [join the translators](https://crwd.in/consul) to help us complete existing languages, or contact us through [Consul Democracy's discussions](https://github.com/consuldemocracy/consuldemocracy/discussions) to become a proofreader and validate translators' contributions.
If your language isn't already present in the Crowdin project, please [open an issue](https://github.com/consuldemocracy/consuldemocracy/issues/new?title=New%20language&body=Hello%20I%20would%20like%20to%20have%20my%20language%20INSERT%20YOUR%20LANGUAGE%20NAME%20added%20to%20Consul%20Democracy) and we'll set it up in a breeze.
If you want to check existing translations of the user-facing texts you can find them organized in YML files under `config/locales/` folder. Take a look at the official Ruby on Rails [internationalization guide](http://guides.rubyonrails.org/i18n.html) to better understand the translations system.
The existing translations of the user-facing texts are organized in YAML files under the `config/locales/` folder. Take a look at the official Ruby on Rails [internationalization guide](http://guides.rubyonrails.org/i18n.html) to better understand the translations system.
## Custom Texts
## Custom texts
Since Consul Democracy is always evolving with new features, and in order to make your fork easier to be updated, we strongly recommend translation files not to be modified, but instead "overwritten" with custom translation files in case a text needs to be customized for you.
Since Consul Democracy is always evolving with new features, and in order to make it easier to update your fork, we strongly recommend that translation files aren't modified, but instead "overwritten" with custom translation files in case you need to customize a text.
So if you just want to change some of the existing texts, you can just drop your changes at the `config/locales/custom/` folder. We strongly recommend to include only those texts that you want to change instead of a whole copy of the original file. For example if you want to customize the text "Ayuntamiento de Madrid, 2016" that appears on every page's footer, firstly you want to locate where it's used (`app/views/layouts/_footer.html.erb`) and look at the locale identifier inside the code:
So, if you'd like to change some of the existing texts, you can add your changes to the `config/locales/custom/` folder. You should only include the texts you'd like to change instead of copying the original file. For example, if you'd like to customize the text "CONSUL DEMOCRACY, 2024" (or the current year) that appears on the footer of every page, first locate where it's used (in this case, `app/components/layouts/footer_component.html.erb`) and look at the locale identifier inside the code:
```ruby
```erb
<%= t("layouts.footer.copyright", year: Time.current.year) %>
```
Then find the file where this identifier will be located (in that case `config/locales/es/general.yml`) following this structure (we're only displaying the relevant parts in the following snippet):
Then find the file where this identifier will be located (in this case, `config/locales/en/general.yml`), and create a file under `config/locales/custom/` (in this case, create a file named `config/locales/custom/en/general.yml`) with the following content:
```yml
es:
en:
layouts:
footer:
copyright: Ayuntamiento de Madrid, %{year}
copyright: Your Organization, %{year}
```
In order to customize it, you should create a new file `config/locales/custom/es/general.yml` with just that content, and change "Ayuntamiento de Madrid" with our organization name. We strongly recommend to make copies from `config/locales/` and modify or delete the lines as needed to keep the indentation structure and avoid issues.
Note that custom locale files should only include your custom texts and not the original texts. This way it'll be easier to upgrade to a new version of Consul Democracy.
## Maintaining your Custom Texts & Languages
## Maintaining your custom texts and languages
Consul Democracy has the [i18n-tasks](https://github.com/glebm/i18n-tasks) gem, it's an awesome helping tool to manage i18n translations. Just check `i18n-tasks health` for a nice report.
Consul Democracy uses the [i18n-tasks](https://github.com/glebm/i18n-tasks) gem, which is an awesome tool to manage translations. Run `i18n-tasks health` for a nice report.
If you have a custom language different than English, you should add it to the [i18n-tasks.yml config file both `base_locale` and `locales`](https://github.com/consuldemocracy/consuldemocracy/blob/master/config/i18n-tasks.yml#L4-L7) variables so your language files will be checked as well.
If you have a custom language different than English, you should add it to both `base_locale` and `locales` variables in the [i18n-tasks.yml config file](https://github.com/consuldemocracy/consuldemocracy/blob/master/config/i18n-tasks.yml#L3-L6), so your language files will be checked as well.

View File

@@ -29,7 +29,7 @@
* [Personalización](customization/customization.md)
* [Introducción](customization/introduction.md)
* [Traducciones y Textos](customization/translations.md)
* [Traducciones y textos](customization/translations.md)
* [Imágenes](customization/images.md)
* [Estilos con CSS](customization/css.md)
* [JavaScript](customization/javascript.md)

View File

@@ -1,7 +1,7 @@
# Personalización del código
* [Introducción](introduction.md)
* [Traducciones y Textos](translations.md)
* [Traducciones y textos](translations.md)
* [Imágenes](images.md)
* [Estilos con CSS](css.md)
* [JavaScript](javascript.md)

View File

@@ -1,39 +1,38 @@
# Traducciones y Textos
# Personalización de traducciones y textos
## Traducciones
Actualmente Consul Democracy esta traducido total o parcialmente a multiples idiomas, visita el proyecto en [Crowdin](https://translate.consuldemocracy.org/)
Actualmente Consul Democracy está traducido total o parcialmente a múltiples idiomas. Visita el [proyecto en Crowdin](https://translate.consuldemocracy.org/) para comprobar el estado de las traducciones.
[Únete a los traductores](https://crwd.in/consul) para ayudar a completar los existentes, o contacta con nosotros a través del [gitter de Consul Democracy](https://gitter.im/consul/consul) para convertirte en Revisor y validar las contribuciones de los traductores.
[Únete a los traductores](https://crwd.in/consul) para ayudar a completar los idiomas existentes, o contacta con nosotros a través de [las conversaciones de Consul Democracy](https://github.com/consuldemocracy/consuldemocracy/discussions) para convertirte en revisor y validar las contribuciones de los traductores.
En el caso de que tu lenguage no este presente en el proyecto de Crowdin, por favor [abre una incicencia](https://github.com/consuldemocracy/consuldemocracy/issues/new?title=New%20language&body=Hello%20I%20would%20like%20to%20have%20my%20language%20INSERT%20YOUR%20LANGUAGE%20NAME%20added%20to%20Consul%20Democracy) y lo añadiremos rápidamente.
En el caso de que tu idioma no esté presente en el proyecto de Crowdin, por favor [abre una incidencia](https://github.com/consuldemocracy/consuldemocracy/issues/new?title=New%20language&body=Hello%20I%20would%20like%20to%20have%20my%20language%20INSERT%20YOUR%20LANGUAGE%20NAME%20added%20to%20Consul%20Democracy) y lo añadiremos rápidamente.
Si quieres ver las traducciones de los textos de la web, puedes encontrarlos en los ficheros formato YML disponibles en `config/locales/`. Puedes leer la [guía de internacionalización](http://guides.rubyonrails.org/i18n.html) de Ruby on Rails sobre como funciona este sistema.
Si quieres ver las traducciones de los textos de la web, puedes encontrarlos en los ficheros en formato YAML disponibles en `config/locales/`. Puedes leer la [guía de internacionalización](http://guides.rubyonrails.org/i18n.html) de Ruby on Rails para aprender cómo funciona este sistema.
## Textos personalizados
Dado que Consul Democracy está en evolución continua con nuevas funcionalidades, y para que mantener tu fork actualizado sea más sencillo, recomendamos no modificar los ficheros de traducciones, es una mejor idea "sobreescribirlos" usando ficheros personalizados en caso de necesidad de alterar un texto.
Dado que Consul Democracy está en evolución continua con nuevas funcionalidades, y para que mantener tu "fork" actualizado sea más sencillo, recomendamos no modificar los ficheros de traducciones sino sobrescribirlos usando ficheros personalizados en caso de que quieras cambiar un texto.
Así pues las adaptaciones las debes poner en el directorio `config/locales/custom/`, recomendamos poner solo los textos que quieras personalizar. Por ejemplo si quieres personalizar el texto de "Ayuntamiento de Madrid, 2016" que se encuentra en el footer en todas las páginas, primero debemos ubicar en que plantilla se encuentra (`app/views/layouts/_footer.html.erb`), vemos que en el código pone lo siguiente:
Así que, para cambiar algunos de los textos existentes, puedes añadir tus cambios en el directorio `config/locales/custom/`. Recomendamos encarecidamente poner solamente los textos que quieras personalizar en lugar de copiar todo el contenido del archivo original. Por ejemplo, si quieres personalizar el texto "CONSUL DEMOCRACY, 2024" (o el año actual) que se encuentra en el pie de página, primero debemos encontrar dónde se utiliza (en este caso, `app/components/layouts/footer_component.html.erb`), y comprobar el identificador de traducción que aparece en el código:
```ruby
```erb
<%= t("layouts.footer.copyright", year: Time.current.year) %>
```
Y que en el fichero `config/locales/es/general.yml` sigue esta estructura (solo ponemos lo relevante para este caso):
Localiza el fichero en el que se encuentra este identificador (en este caso, `config/locales/es/general.yml`) y crea un archivo en `config/locales/custom/` (en este caso, crea el archivo `config/locales/custom/es/general.yml`) con el siguiente contenido:
```yml
es:
layouts:
footer:
copyright: Ayuntamiento de Madrid, %{year}
copyright: Tu Organización, %{year}
```
Si creamos el fichero `config/locales/custom/es/general.yml` y modificamos "Ayuntamiento de Madrid" por el nombre de la organización que se este haciendo la modificación. Recomendamos directamente copiar los ficheros `config/locales/` e ir revisando y corrigiendo las que querramos, borrando las líneas que no querramos traducir.
Es importante que los ficheros de `config/locales/custom/` solamente incluyan textos personalizados y no los textos originales. De este modo, será más fácil actualizar a una nueva versión de Consul Democracy.
## Mantener tus Textos Personalizados y Lenguajes
## Mantener tus textos personalizados y lenguajes
Consul Democracy tiene la gema [i18n-tasks](https://github.com/glebm/i18n-tasks), es una herramienta estupenda para gestionar textos i18n. Prueba en tu consola `i18n-tasks health` para ver un reporte de estado.
Consul Democracy utiliza la gema [i18n-tasks](https://github.com/glebm/i18n-tasks), que es una herramienta estupenda para gestionar traducciones. Ejecuta en una consola `i18n-tasks health` para ver un informe de estado.
Si tienes un lenguaje propio diferente al Inglés, deberias añadirlo al fichero de configuración [i18n-tasks.yml para las variables `base_locale` y `locales`](https://github.com/consuldemocracy/consuldemocracy/blob/master/config/i18n-tasks.yml#L4-L7) de forma que los ficheros de tu idioma también sean comprobados.
Si tienes un idioma propio diferente al inglés, deberías añadirlo a las variables `base_locale` y `locales` del [fichero de configuración i18n-tasks.yml](https://github.com/consuldemocracy/consuldemocracy/blob/master/config/i18n-tasks.yml#L3-L6), de forma que los ficheros de tu idioma también sean comprobados.