After some weeks of passive thinking and some days of tinkering I’m ready to announce a half-baked version of Ordbok, a localisation library for SketchUp extensions.
I think a lot of people are quite frustrated about LangHandler, both it’s unusual style and lack of features. There has been other attempts to localization in the past, e.g. @thomthom’s Babelfish (wish is where I learned string interpolation from).
This library aims to take SketchUp extension localization one step further, with features inspired by rails/l18n.
Some notable features are:
- String interpolation
OB = Ordbok.new OB[:message_notification, count: 14] # => "You have 14 new messages."
- Simple pluralization rules
(Pick different phrases based on count)
OB = Ordbok.new OB[:message_notification, count: 1] # => "You have 1 new message." # Note 'message' being in singular!
- Phrase grouping
(Required for pluralization)
OB = Ordbok.new OB["errors.file_missing", count: 1] # => "Could not perform operation.\n\n1 file is missing."
The library is also built around descriptive keys, rather than full English strings, which both makes the code more readable and prevents translation errors due to homonyms in the source language(different phrases that just happens to spell out the same).
The library is not 100% finished but ready to be tested out. Enjoy!