Last active
December 18, 2015 05:08
-
-
Save markhealey/5729989 to your computer and use it in GitHub Desktop.
i18n perhaps
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* In Container, by Container Developer | |
*/ | |
F2.init({ | |
i18n: { | |
locale: 'fr-fr' //container-provided default for French, France | |
} | |
}) | |
/** | |
* App Manifest, by App Developer | |
*/ | |
{ | |
scripts:['/appclass.js'], | |
styles:[], | |
apps:[{ | |
data:{}, | |
html:'<p>My app</p>', | |
i18n: { | |
supported_locale: ['en-us','fr-fr']//default 1st | |
} | |
}] | |
} | |
/** | |
* AppClass.js, by App Developer | |
*/ | |
var drawHeader = function(){ | |
return '<h1>' + i18n('My App Header') + '</h1>'; | |
} | |
var i18n = function(str){ | |
var map = { | |
'My App Header': { | |
fr: 'My App tête' | |
} | |
} | |
//Container defined F2.i18n.locale = 'fr-fr'... | |
var currentLang = F2.i18n.locale.split('-')[0] || appConfig.defaultLang; //'fr' or 'en' | |
if (currentLang == 'en'){ | |
return str; | |
} else { | |
//look up translation in map | |
return map[str][currentLang]; //My App tête | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment