Skip to content

I18n localization works only for single language #150

@hoenth

Description

@hoenth

In our app, we allow the user to switch between different translations. We were excited to see that recurring_select offers localization, but it appears that one for one language, that cannot be dynamically changed.

I believe this is because the gem is simple overwriting the $.fn.recurring_select.texts object. It only contains one set of translations, based on whatever file is being loaded last.

For example, I adding a spanish translation coffee file in the assets/javascripts/recurring_select folder called es.js.coffee

$.fn.recurring_select.texts = {
  locale_iso_code: "es"
  repeat: "Recurrencia"
  last_day: "Último día"
  frequency: "Frecuencia"
  daily: "Diaria"
  weekly: "Semanal"
  monthly: "Mensual"
  yearly: "Anual"
  every: "Cada"
  days: "día(s)"
  weeks_on: "semana(s)"
  months: "mes(es)"
  years: "año(s)"
  first_day_of_week: 1
  day_of_month: "Día del mes"
  day_of_week: "Día de la semana"
  cancel: "Cancelar"
  summary: "Resumen"
  ok: "OK"
  days_first_letter: ["D", "L", "M", "M", "J", "V", "S" ]
  order: ["1er", "2ème", "3ème", "4ème", "5ème", "Dernier"]
  show_week: [true, true, true, true, false, false]
}

Then included this file in my application.js file after I include recurring_select.

This overwrites the values in the texts object, and all translations were then in spanish. This is fine if the only language you ever need is one. But if users can dynamically switch between languages, which works in the rails app out of the box, then this implementation won't work.

I'm not seeing anywhere in the code where different locales files are selected based on the current locales value (I18n.locale)

It seems to me that the current locales value would have to be set as an element's data value, or as a js value, on each request. And the recurring_select would pull the correct text values from master locales file using whatever is the current selected locale.

I'd be grateful for any suggestions on how to modify recurring_select to do this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions