Object notation in i18n translations. (Sails.js 0.10.x)

467 views
Skip to first unread message

Dave Sag

unread,
Jun 21, 2014, 10:33:24 AM6/21/14
to sai...@googlegroups.com
I have the following in my `config/locales/en.json`

    {
      "countries": {
        "au": {
          "name": "Australia",
          "fiatCurrency": "AUD",
          "subnationalDivisions": {
            "NSW": "New South Wales",
            "WA": "Western Australia",
            "VIC": "Victoria",
            "QLD": "Queensland",
            "TAS": "Tasmania",
            "SA": "South Australia",
            "NT": "Northern Territory",
            "ACT": "Australian Capital Territory"
          }
        }
      }
    }
    
My `config/i18n.js` file looks like

    module.exports.i18n = {

      // Which locales are supported?
      locales: ['en', 'es', 'fr', 'de'],

      objectNotation: true

    };

In my controller I am trying to retrieve the correct `subnationalDivision` name via

    res.i18n("countries." + country + ".subnationalDivisions." + state)
    
but that just gives me `"countries.au.subnationalDivisions.ACT"`, not `"Australian Capital Territory"`

I've checked and trivial translations work fine but anything involving the use of objectNotation is ignored.

Does anyone have any examples of more complex i18n stuff with Sails?

As ever I've popped this question into Stackoverflow


Further to this, is there a way I can break the translations up into multiple files?  Eg creating a /config/locales/en/ folder with separate translations for countries, various views, controls, etc.

Dave Sag

unread,
Jun 21, 2014, 8:11:42 PM6/21/14
to sai...@googlegroups.com
Further to this, I have generated a simple sails0.10 app as a canonical example of the problem, and raised an issue on Github about it.  It seems to be a bug.


Cheers

Dave
Reply all
Reply to author
Forward
0 new messages