开发者

SilverStripe blog module translation

开发者 https://www.devze.com 2023-03-08 08:34 出处:网络
I noticed that the blog module for SS have hardcoded pieces of text - that I need to translate (in french). I found that the code is in /blog/templates/Includes/BlogSummary.ss but when I modify it, no

I noticed that the blog module for SS have hardcoded pieces of text - that I need to translate (in french). I found that the code is in /blog/templates/Includes/BlogSummary.ss but when I modify it, nothing changes on front-end...

I tried to run a /dev/build/?flush=all bu开发者_如何学Pythont nothing... still.

Any idea? Help would be much appreciated. Thanks in advance.


Have you set your locale? I recently set up a site in English & Spanish and used this setup.

//  add similar code to your _config.php file
#Translatable::set_default_locale('en_US'); 
#Translatable::set_allowed_locales(array( 
#   'en_US',
#   'es_US'
#));

Further, I had to add i18n::set_locale() code to the init() function in my content controller to get the template translations to work.

<?php

class SmartLanguageExtension extends DataObjectDecorator {

    function contentcontrollerInit() {
        i18n::set_locale(Translatable::get_current_locale());
    }

}

In my case, I added an extension to the Page_Controller class for reusability later on.

//  _config.php file
Object::add_extension('Page', 'SmartLanguageExtension');
0

精彩评论

暂无评论...
验证码 换一张
取 消