Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
unified directory for plugin translation files
#11
ccagle8 Wrote:
  • Allow developers to create their own folder within their plugin structure like this: '/myplugin-folder/lang/'
  • Give them a function that allows them to "merge" their language file (which is an array just like before) with the site-wide language file. Something like this: i18n_merge('../path-to-my-plugin/lang/en_US.php');

Nice compromise, but I would change the function signature to i18n_merge('myplugin-folder', 'mylanguage') where 'mylanguage' is optional and set to $LANG if not given.
  • that way the plugin's directory structure regarding translations is enforced,
  • the keys must be automatically prefixed with 'myplugin-foler/' by the i18n_merge function, otherwise plugins will overwrite each other's texts
  • texts should be merged (although with a prefix that's not really important), i.e. if the key already exists, it is not overwritten
  • i18n_merge returns true if the language file exists, false otherwise.

Normally the admin language and the frontend language are the same and using english as default is reasonable, thus the standard code in plugins would be:

Code:
if (!i18n_merge('myplugin')) i18n_merge('myplugin', 'en_US'); // or another default language
...
i18n('PAGES'); // accessing standard GetSimple text
i18n('myplugin/MYTEXT'); // accessing plugin specific text

I don't think renaming the file to language.php is a good idea - it means one more manual step on installation for the user, even if his language is supported by the plugin. And with the I18N plugin or a future GetSimple supporting one language per user it would not even work.

It's as easy for the user to copy a file to say "it-IT.php" and translate it. And when he is happy with it, he should be encouraged to send it to the plugin developer.
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply


Messages In This Thread
unified directory for plugin translation files - by mvlcek - 2011-03-16, 23:19:23



Users browsing this thread: 2 Guest(s)