Reputation: 1577
I am migrating a website from SS 2.4 to SS 3.0 and I am having an immensely difficult time due to the fact that the SilverStripe documentation is full of dead links (about every link I have clicked on the 3.0.0 documentation page is dead) and holes such as incomplete sentences or pages that show up among search results but cannot be reached.
Specifically, the website I am working on runs in two locales (en_US and fr_FR) and I used (in SS 2.4) to use i18n::include_locale_file
. Now, after finding the appropriate modules and upgrading the custom code, I get a deprecation notice that I don't know how to solve and to which web searches bring no answer:
[User Deprecated] i18n::include_locale_file is deprecated. Use Zend_Translate instead.
The problem is that there's zero example of what is to be done. There's no upgrade path available to be followed. I just don't get how I can replace old code such as this:
i18n::include_locale_file('framework', 'fr_FR');
global $lang;
if(array_key_exists('fr_FR', $lang) && is_array($lang['fr_FR'])) {
$lang['fr_FR'] = array_merge($lang['fr_FR'], $lang['fr_FR']);
} else {
$lang['fr_FR'] = $lang['fr_FR'];
}
This was standard code in SS 2.4 and can be found for instance in language files of sapphire and cms.
As I understand it, Zend_Translate is part of a framework. Is there a possibility to express simply the inclusion of another translation file? Or the layering of two translation files?
I thought of using the yml converter so I can be in line with the recommendations but it works as CLI on a Unix system and I'm working on a Windows system. With all the time I have spent on this migration, and the frustration with the documentation, I now regret having picked SS but I can only go forward. Therefore, I'm looking for a simple solution, not one that would require installing a virtual machine.
Thanks.
Upvotes: 1
Views: 70
Reputation: 4626
you have php files as lang files? e.g. mysite/lang/fr_FR.php ? You'll have to move this to yml files or use Zend_Translate instead ;)
See https://github.com/jakr/miscellaneous-wiki/wiki/SilverStripe-3-Quick-Upgrade-Guide#translation-file-format-changed-from-php-to-yml and https://docs.silverstripe.org/en/3.0/changelogs/3.0.0#zend-translate
From the latter, define in your /mysite/config.php:
i18n::register_translator(
new Zend_Translate(array(
'adapter' => 'i18nSSLegacyAdapter',
'locale' => i18n::default_locale(),
'disableNotices' => true,
)),
'legacy',
9 // priority lower than standard translator
);
to get the old php files working again. Depending on how many language strings you have i'd move it to .yml.
Upvotes: 0