ezrpg-legacy / ezrpg-2.0.X-discontinued-

http://ezrpgproject.net
Other
6 stars 0 forks source link

Language system #26

Open JakeBooher opened 11 years ago

JakeBooher commented 11 years ago

Instead of having phrases and such hardcoded into the templates, modules, etc. we should have them loaded from a file so that each game can be run in multiple languages, and make it easier for the game owner to change the language to their own.

uaktags commented 11 years ago

Wouldn't that be how it'd work? Template files will have to use an array like $lang['site-name'] and that'd be set by a language file associated to that of our settings. Wed provide a lang.en.php file for the basic stuff, then modules and whatnot will also provide their own lang.en.php files, perhaps with a suffix of the module name or something.

During initialization wed have to load the language arrays and perhaps even cache the results since language files don't change.

As a failsafe, if there's no template tags for that selected language, it'll auto English or the modules default (expanded module setting) language.

A catch will have to be implemented though, to return null if a template for some reason tries to load an tag that doesn't exist. Like $lang['sites-name'] would return blank since it doesn't exist but $lang['site-name'] would return the game name from language file.

JakeBooher commented 11 years ago

Pretty much, but have it separated into multiple files, each module could have its own file that it would load on that module, and there would be a global language file that would be loaded for every module

uaktags commented 11 years ago

Yea. Perhaps a directory system for languages.

./languages/en/lang_en_modulename.php Or ./languages/en/module_name/lang_en.php ./languages/en/master/lang_en.php

You load the master first and then array merge the other language files. Since languages may have to be used outside of just that modules page, well have to load them all into global at least once.