Ask A Question


You’re not receiving notifications from this thread.

local_time gem: Where to place the I18n file to modify the string literals?

Ernesto Gimeno asked in Rails
EDIT. Finally solved, I pasted the keys from into application.js like that:

LocalTime.config.i18n["es"] = {
    date: {
      dayNames: [
      abbrDayNames: ["Dom", "Lun", "Mar", "Mie", "Ju", "Vie", "Sab"],

then in the same file i placed `LocalTime.config.locale = "es";`


I want to use this gem, which was part of an old episode, but I need to translate the string literals to spanish  in order to use it in my application.

According to their docs, you can just manipulate this file ( that contains the english defaults, which I did since it looks the easiest way to do it:

The problem is, I don't know where to place this file to get the translated strings loaded, the texts remain as per default. I have modified locales yml files in the past to translate other gems such as devise, but I don't know hot to deal with that.

I have tried in several paths such as:



The answer must be pretty obvious but I can't find it :(, any help would be appreciated.

Doesn't it use the i18n yml in `config/locale/<xx>.yml`? 
Great base/starting point is
I don't think so, that's the reason for my confusion.

They point to this file in their docs which contains the default english translations:
Did you try duplicating all the keys below `en:` for your Spanish translation? I'd expect you can use the same file.

I see you can you pass in the format as a :symbol (`
<%= local_time(date, :long) %>
`), this should look for it in the `config/locale/xx.yml` files.

I tried to copy the keys in locales/en.yml but I get this syntax error:

EDIT. Checking with YAMLLint, looks like the spaces between : and [ are not allowed.

I18n::InvalidLocaleData at /orderscan not load translations from /vagrant/src/pascual-apps/config/locales/en.yml: #&lt;Psych::SyntaxError: (/vagrant/src/pascual-apps/config/locales/en.yml): did not find expected ',' or ']' while parsing a flow sequence at line 34 column 17&gt;

Line 34 is the one for dayNames:

dayNames: [
abbrDayNames: [

I managed to get  valid YML, translated it,  but the name of the months remains in english.

EDIT. In this issue they talk about it, tried what the last comment says, still no luck.
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 82,329+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.