I'm working on a component that uses ajax by initializing joomla in a separate script where I can send requests. I am trying to apply the logged in user's language (English or French) in any content or messages I send back from my component by using getLanguage() and load(). The code might look something like this:
This works except for the case where I use an English override INI file. If an English override INI file is present, it overrides French labels as well.
Code: Select all
//Require stuff here $app = JFactory::getApplication('site'); $app->initialise(); $user = JFactory::getUser(); $language = JFactory::getLanguage(); $language->load('my_component', JPATH_SITE, $user->getParam('language'), true); //Do stuff here
It seems like this is because the override file is loaded in the Language constructor (/libraries/src/language) and when load() is called for a different language, the overrides have already been set to the site default language. There doesn't seem to be a method to update the overrides once Language has been constructed.
1) Is there a way to change the site language BEFORE the Language constructor is called? Maybe a method I could use on the Joomla application to make the language align with the user.
2) Is there a way to reload the override data AFTER the Language constructor is called? I can call load() to reload a new language file but it would be helpful if I could reload the overrides as well.
3) If neither #1 or #2 are possible, should this be an issue for the Joomla dev team? It would be nice to be able to have multiple languages AND use overrides when using external scripts for ajax.