using amplify for i18n

Skip to first unread message

Stefano Cudini

Dec 2, 2013, 11:33:53 AM12/2/13
I'm using amplify for the first time

To begin, I'm using to store a json file that contains localized strings for i18n module of my application

anyone ever used to amplify manage i18n?
how did you proceed?

I load a json file on boot, but the problem is that I should refresh this file when the server side json file is updated with new strings

App.loadI18n = function(callback)
var storeKey = "i18n-" + App.lang;

if( ! )
$.getJSON("/i18n/" + App.opts.lang + ".json", function(json) {

App.i18n =, json );

callback( App.i18n );
App.i18n =;
callback( App.i18n );

Stefano Cudini

Jan 22, 2014, 10:20:09 PM1/22/14
I do not want to believe that no one has used to amplify this purpose!  :-(

Doug Neiner

Jan 23, 2014, 12:02:05 AM1/23/14
Hi Stefano,

Sorry you had to ping the list twice before getting an answer!

Your JavaScript won’t know your server file has changed, so you’ll need to either automatically expire your storage or use a few other approaches.

You can set an automatic caching length when you store the file:, json, { expires: 24 * 60 * 60 * 1000 }); // cache for 24 hours

Another approach depends on when/how the i18n files change. If they change only when code that uses them changes, and all your JS is rebuilt – you can use a hard coded timestamp that you update in your JS (or as part of your build step) when your code should refresh the store.

You’d want to store that timestamp using after checking if the hardcoded date is greater than the existing stored date. When you have updated the JS and i18n files, this date will be out of sync and you can clear out your i18n cache and reload it.

Or, if you are already versioning your JS, you could compare the version of the app with one you stored in and automatically re-fetch the i18n files when the app version changes.

Hope some of these ideas give you a nice approach short of reaching out to your server to see if the file has changed.

You received this message because you are subscribed to the Google Groups "Amplify" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
For more options, visit

Reply all
Reply to author
0 new messages