Question on languages and extensions
Extensions add their own terminology and language strings to Vanilla, e.g.for the Discussion overview extension:
$Context->Dictionary['DiscussionOverview'] = 'Discussion Overview';
$Context->Dictionary['DiscussionOverviewAsTab'] = 'Show discussion overview in a separate tab';
I translated those strings and put them in the languages/Dutch/definitions.php file:
$Context->Dictionary['DiscussionOverview'] = 'Discussie Overzicht';
$Context->Dictionary['DiscussionOverviewAsTab'] = 'Toon het discussie Overzicht in een aparte tab';
However, the translation was not shown. So I translated the phrases in the extension/<extension_name>/default.php file in-place, but I'm wondering: is this the way it should go? Or is there a way to keep language versions separate for extensions as well?
0
This discussion has been closed.
Comments
if (!array_key_exists('DiscussionOverview', $Context->Dictionary) { $Context->Dictionary['DiscussionOverview'] = 'Discussion Overview'; } if (!array_key_exists('DiscussionOverviewAsTab', $Context->Dictionary) { $Context->Dictionary['DiscussionOverviewAsTab'] = 'Show discussion overview in a separate tab'; }
Or even this:
$ExtensionDict = array(); $ExtensionDict['DiscussionOverview'] = 'Discussion Overview'; $ExtensionDict['DiscussionOverviewAsTab'] = 'Show discussion overview in a separate tab'; $Context->Dictionary = array_merge($ExtensionDict, $Context->Dictionary);
But neither of these feels all that elegant. My questions are: 1. Is there a better way that I've missed? and 2. Is there a consensus on what is the "right way" to do this?
$Context->SetDefinition('DiscussionOverview', 'Discussion Overview');
It only set a default definition, it won't overwrite definitions from definitions.php or conf/language.php