In time to come I would like to replace the existing language system with something like:
// this will load the settings and welcome page
// lexicons (dictionary)
$modx->lexicon->load(’settings,welcome’);
// use either
echo $_lang[’welcome_msg’];
// or
echo $modx->lexicon->get(’welcome_msg’);
// or from a page to be processed by the parser
echo "[[%welcome_msg]]";
Calling $modx->lexicon->load() will load all available lexicons
What do you think?
I’ve been thinking that we really need something like this for a while now. It looks like a good start to me. It should be easy to add on whatever sort of functionality we want, like inline translation editing, auto-translate using translation web services, auto-linking keywords to documentation and anything else we can dream up.
:)
You mean something like:
// here we first look inside the db for the french lexicon
//if not found then use an online service (this might be very slow)
echo $modx->lexicon->translate(’welcome_msg’,’french’);
// here we will use an online service to translate texts
// (this might be very slow)
echo $modx->lexicon->translateText(’Hi, I like MODx’,’french’);
In my first post the when the $modx->lexicon->load() function is called it will load the terms for the selected language.
Another example is:
// if the language is not available then the system
// will default to english
$modx->lexicon->setLang(’french’);
$modx->lexicon->load(’QuickEdit’);
To add a new term:
$modx->lexicon->add($term,$text,$lang=’english’,$category=’’);
example:
// add english message
$modx->lexicon->add(’hello_msg’,’Hello world’);
// add french message
$modx->lexicon->add(’hello_msg’,’Bonjour monde’,’french’);
yea, that’s looking good.
We need to also consider how snippets, modules, plugins, etc will be able to register their own translation entries.
I think that the language selection should happen automatically, with the option of selecting one or more "base" languages like English. The whole thing should of course be extendible with plugins also, which might be a good way to implement the online translation features. Inline translating could work too via a plugin, if a phrase had to be reverted to a "base" language it could be highligted or have a "translate this" button.
I’ve seen enough multi-lingual systems (especially modular ones) to know that translation is typically a 75-90% thing. Rarely does a translation cover everything because people just don’t keep up with them. I think we need to find a way to clean up that last 25-10% as easily as possible. Also, we should realize that some things may not even have English translations.
I think we’re definitely headed down the right road. If we can just build a flexible enough OO class and think ahead as much as possible it sholud be simple to extend it as much as we want without breaking backward compatability.
-
MODX Staff
- 12,272 Posts
Um... wow guys... and it just keep going on and on... how cool: online translations!
Ryan Thrash, MODX Co-Founder
Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
To load a lexicon (dictionary) form the web page we could use:
[[%#LexiconName:EN]] where :EN is the optional language code
Example: [[%#cms_welcomepage]]
To display a lexicon term use: [[%LexiconTerm]]
Example: [[%welcome_msg]]
This means that we could then do this on a web page:
[[%#my_dictionary]]
[[%hello_word]]
or maybe something like:
[[%#my_dictionary:FR]] // here we load the french version on of my_dictionary
[[%hello_word]]
Any suggestions or ideas?
-
MODX Staff
- 12,272 Posts
So the "#" indicates which dictionary to load? Where will it know where to go for that? If the same dictionay is used on multiple pages, will it use a cached dict across pages?
And what about for spontaneouslly generate content that needs on the fly translation, like a press release or a web page itself... hmmm....
Not being helpful, but just trying to think through things.
Something we might consider is declaring the languages we anticipate using for a particular site in the config section. Then we’d need to be able to store copies of each content field as pages are added. Hmmm.... more to think about.
Ryan Thrash, MODX Co-Founder
Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me