AlexanderRemizov / Krebs
Project infos
| License | MIT |
| Tags | localisation, multylanguage, language |
| Creation date | 2015-11-11 |
| Website |
Monticello registration
About Krebs
Simple little framework for localisation app
-= DEFINE A SHORTCUT IN THE CODE =-
You can send shortcut as block with message.
for example:
[ 'shortcut' ] translateItKrebs
or
[ 'shortcut' ] translateItKrebsOn: 'eng' "'eng' - language for one specific shortcut"
-= DEFINE A DICTIONARIES CONTROLLER =-
You can create subclass KrebsDictionariesController. You can define metod #defaultLanguage. for example:
MyKrebsDictionariesController>>defaultLanguage ^ 'eng'
-= DEFINE A DICTIONARIES =-
You can create subclass Dictionary . You can adding in your dictoinary info about language. (default language key - 'language' ) for example:
MyEngDictionary>>initialize: n super initialize: n. self at: 'language' put: 'eng'
You can adding shortcuts and text (shortcut - key, text - value)
-= ADD DICTIONARIES TO OBJECT =-
Your Class must have method #hereMyDictionaryKrebs method should return dictionaries controller and dictoinaries. for example:
- If the dictionaries controller and dictionaries defined for the first time.
hereMyDictionaryKrebs ^ MyKrebsDictionariesController add: MyDictionary on: self
or
hereMyDictionaryKrebs ^ MyKrebsDictionariesController add: {MyDictionary . MyDictionary2} on: self
- If you define an additional controller with dictionaries.
hereMyDictionaryKrebs ^ { (MyKrebsDictionariesController2 add: {MyDictionary3 . MyDictionary4} on: self) . MyKrebsDictionariesController }
(if the shortcut is not found in dictionaries of the MyKrebsDictionariesController2, then shortcut will be search in dictionaries MyKrebsDictionariesController)
-= SWITH LANGUAGES =-
You can send message #switchToLanguage: for example:
self class hereMyDictionaryKrebs switchToLanguage: 'russian' (because controller is a singleton, the language will be changed for all applications using this controller)
-= RSET A DICTIONARIES CONTROLLER =-
KrebsDictionariesController is singleton (look KrebsDictionariesController>>uniqueInstance). You can send message #reset for controller class
-= BUGS =-
If your class not responds to #hereMyDictionaryKrebs, you will see instead a shortcut a warning: 'Attention! Check #hereMyDictionaryKrebs'
If Dictionaries not found - return shortcut string.
If Shortcuts not found - return shortcut string.
If languageKey not found in Dictionaries - return shortcut string.
If language not found - will be use default language.
-= DEBUG =-
You can enable the #debug in your controller. for example:
MyKrebsDictionariesController debug: true.
Then all mistakes will be collected in the variable #bugs in the your controller
