Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Extension Language Loader
klip
New
Extension Language Loader
0
This discussion has been closed.
Comments
I cannot sleep (I'm being sick, emptying nose all the night) so I was just thinking about improving this add-on, so here is my todo-list:
- easy install and uninstall of Loader into conf/language.php from Settings without destroying the content in the file
- create a cached array of all possible language files to load, so it doesn't search for the files every time Vanilla is refreshed:
array( 'LANGUAGE1' => Array( 'extensions/Notify/LANGUAGE1.php', ... , 'conf/LANGUAGE1.php' ), 'LANGUAGE2' => Array( 'extensions/Statistics/LANGUAGE2.php' ), 'LANGUAGE3' => Array( 'extensions/Statistics/LANGUAGE3.php', 'language/LANGUAGE3/extensioins/languageContactForm.php' ), )
- set cache timeout for this cached array, allow to recreat the array by click from Settings (also maybe check last modification timestamp of conf/extensions.php to decide to recreate it automatically)
- check the language priorities of user and include all language files begining with language with lowest priority, so definitions included in languages with higher priority would be overdefined - this would probably mean to load also main language definitions
- make it work with LanguageSelector/ChooseLanguage after getting familiar with a code in those add-ons
- allow user to setup priorities of loaded language definitions in Settings - allow to read this settings from browser
- maybe merge this add-on with ChooseLanguage/LanguageSelector, improve ChooseLanguage/LanguageSelector to cooperate with this add-on, make a new add-on for language selecting, or improve this add-on and rename it to something more general if the add-on would be general solution for localization.
Any suggestions?
if LANGUAGE.PHP INSTALLED it seemed to switch only extensions definitions (not the main LANGUAGE/definitions.php)
so if it is going to work with multiple languages and their priorities, then it would be necessary to write new add-on or improve LanguageSelector for this feature, which should be optional.
Anyway I found a small bug in the file include_languages.php, which will be fixed in next update, so please if you don't want to wait, replace (line 52):
if ( ( $dh = opendir( $addons_translation_folder ) ) !== false ) {
by this
if ( file_exists( $addons_translation_folder ) && ( $dh = opendir( $addons_translation_folder ) ) !== false ) {
install it by running svn checkout in /path/to/vanilla/extensions/ and be sure there is not ExtensionLanguageLoader folder (i.e. installed):
cd /path/to/vanilla/extensions/ mv ExtensionLanguageLoader ExtensionLanguageLoader.backup-to-delete svn co svn://tomas.klapka.cz/var/svn-repos/vanilla/extensions/ExtensionLanguageLoader/trunk ExtensionLanguageLoader
then you can update any time by calling svn update in /path/to/vanilla/extensions/ExtensionLanguageLoader/ folder
cd /path/to/vanilla/extensions/ExtensionLanguageLoader/ svn update
you need to have subversion client installed on your system
changelog:
- new folder structure
- code installed into conf/language.php is smaller
- adds language code as a prefix for definitions in languages with lower priority then main
- loads all language definitions, not only extensions (I'm considering renaming of this add-on to Language Loader)
- implemented cache + timeout
- settings panel for admin to enable/disable cache, set cache timeout in hours and manually reset cache
- rewritten install code
- added uninstall code + uninstalls code from 1.0
- added delegation to ExtensionForm.PreExtensionDisable so it is supposed to uninstall itself when disabled but it doesn't work because extensions are no longer loaded by ajax
- reads priorities from $Configuration['LANGUAGE_PRIORITIES'] if they are set, so you can set there for example: 'French,Turkish,Catalan'. So it should be easy to improve any language selector to set this and pass it to Language Loader
todo:
- more testing
- solve uninstall if there won't be core change
- make better install if there will be core change
- search for more places and more filenames (English, english, en, en-ca, en-us, en-gb)
- add user setting somewhere into account page to let user choose if s/he wants to display language code as prefix for definitions from lower then main languages
considering:
- write add-on just for installing and uninstalling 'include' lines code to conf/whatever.php and able to run some custom code when extension, which installed such code, is disabled
latest version is in:
svn co svn://tomas.klapka.cz/vanilla/extensions/ExtensionLanguageLoader/trunk ExtensionLanguageLoader
Should upgrade from 1.0 without any problem and also removes the code (from conf/language.php) of 1.0 if you still have it in system after removing this extension from your system.
todo:
- if there will be a core change allowing to include extensions in ajax calls, then make better uninstall
- if there will be a core change allowing to replace standard langauge loading, then make better install
- find a way how to add a language code prefix for default definitions if english doesn't have the highest priority (seems to be impossible at the moment)
- improve LanguageSelector or write own extension allowing to setup priorities on the user level
reconsidered: I decided to not implement this because there is a cache and if you change this settings it has to timeout to recreate it. Still it is possible to make different cache for both cases. So still thinking about it, but priority of this is very low at the moment.
So that's it. I'm not going to do any development on this in a near future, but fixing bugs.
Also this add-on is not supported by extension and language add-on developers/translators yet, please support it by translating extensions and saving them into the proper places of your add-on (see the first post/add-on description). Though this version loads also the base dictionary data, not only extensions', so if you don't want to have only your language and then only english if there is not a definition in your language, then you can give it a try.
Enjoy