mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
ENHANCEMENT Adjusted SearchForm, Debug, ErrorPage, SiteTree to using locales instead of lang codes
API CHANGE Changed Translatable datamodel to use locales ("en_US") instead of lang values ("en). API CHANGE Changed Translatable::$default_lang to $default_locale, Translatable::$reading_lang to $reading_locale API CHANGE Using "locale" instead of "lang" in Translatable::choose_site_lang() to auto-detect language from cookies or GET parameters API CHANGE Deprecated Translatable::is_default_lang(), set_default_lang(), get_default_lang(), current_lang(), set_reading_lang(), get_reading_lang(), get_by_lang(), get_one_by_lang() API CHANGE Removed Translatable::get_original() - with the new "translation groups" concept there no longer is an original for a translation BUGFIX Updated MigrateTranslatableTask to new Locale based datamodel git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73468 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
4e5bc0f7fa
commit
7ad7f8dcf2
@ -318,7 +318,7 @@ HTML;
|
||||
* Returns the xml:lang and lang attributes
|
||||
*/
|
||||
function LangAttributes() {
|
||||
$lang = Translatable::current_lang();
|
||||
$lang = Translatable::current_locale();
|
||||
return "xml:lang=\"$lang\" lang=\"$lang\"";
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,7 @@ class ModelAsController extends Controller implements NestedController {
|
||||
if(isset($_REQUEST['debug'])) Debug::message("Using record #$child->ID of type $child->class with URL {$this->urlParams['URLSegment']}");
|
||||
|
||||
// set language
|
||||
if($child->Lang) Translatable::set_reading_lang($child->Lang);
|
||||
if($child->Locale) Translatable::set_reading_locale($child->Locale);
|
||||
|
||||
$controllerClass = "{$child->class}_Controller";
|
||||
|
||||
|
@ -68,7 +68,7 @@ class RootURLController extends Controller {
|
||||
if($homePageOBJ) {
|
||||
$urlSegment = $homePageOBJ->URLSegment;
|
||||
} elseif(Translatable::is_enabled()) {
|
||||
$urlSegment = Translatable::get_homepage_urlsegment_by_language(Translatable::current_lang());
|
||||
$urlSegment = Translatable::get_homepage_urlsegment_by_language(Translatable::current_locale());
|
||||
}
|
||||
|
||||
return ($urlSegment) ? $urlSegment : self::get_default_homepage_urlsegment();
|
||||
|
@ -110,7 +110,7 @@ class ErrorPage extends Page {
|
||||
|
||||
// if the page is published in a language other than default language,
|
||||
// write a specific language version of the HTML page
|
||||
$filePath = self::get_filepath_for_errorcode($this->ErrorCode, $this->Lang);
|
||||
$filePath = self::get_filepath_for_errorcode($this->ErrorCode, $this->Locale);
|
||||
if($fh = fopen($filePath, "w")) {
|
||||
fwrite($fh, $errorContent);
|
||||
fclose($fh);
|
||||
@ -149,7 +149,7 @@ class ErrorPage extends Page {
|
||||
* @return String
|
||||
*/
|
||||
static function get_filepath_for_errorcode($statusCode, $lang = null) {
|
||||
if(Translatable::is_enabled() && $lang && $lang != Translatable::default_lang()) {
|
||||
if(Translatable::is_enabled() && $lang && $lang != Translatable::default_locale()) {
|
||||
return self::$static_filepath . "/error-{$statusCode}-{$lang}.html";
|
||||
} else {
|
||||
return self::$static_filepath . "/error-{$statusCode}.html";
|
||||
|
@ -885,8 +885,8 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
||||
}
|
||||
|
||||
// get the "long" lang name suitable for the HTTP content-language flag (with hyphens instead of underscores)
|
||||
$currentLang = (Translatable::is_enabled()) ? Translatable::current_lang() : i18n::convert_rfc1766(i18n::get_locale());
|
||||
$tags .= "<meta http-equiv=\"Content-Language\" content=\"". $currentLang ."\"/>\n";
|
||||
$currentLang = (Translatable::is_enabled()) ? Translatable::current_locale() : i18n::get_locale();
|
||||
$tags .= "<meta http-equiv=\"Content-Language\" content=\"". i18n::convert_rfc1766($currentLang) ."\"/>\n";
|
||||
|
||||
// DEPRECATED 2.3: Use MetaTags
|
||||
$this->extend('updateMetaTags', $tags);
|
||||
@ -1747,7 +1747,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
||||
|
||||
//TODO: Add integration
|
||||
/*
|
||||
if(Translatable::is_enabled() && $controller->Lang != Translatable::default_lang() && !$this->isTranslation())
|
||||
if(Translatable::is_enabled() && $controller->Locale != Translatable::default_locale() && !$this->isTranslation())
|
||||
$classes .= " untranslated ";
|
||||
*/
|
||||
$classes .= $this->markingClasses();
|
||||
|
@ -3,7 +3,7 @@
|
||||
* The Translatable decorator allows your DataObjects to have versions in different languages,
|
||||
* defining which fields are can be translated.
|
||||
*
|
||||
* Common language names (e.g. 'en') are used in Translatable for
|
||||
* Common language names (e.g. 'en_US') are used in Translatable for
|
||||
* database-entities. On the other hand, the file-based i18n-translations
|
||||
* always have a "locale" (e.g. 'en_US').
|
||||
*
|
||||
@ -23,26 +23,26 @@
|
||||
*
|
||||
* Getting a translation for an existing instance:
|
||||
* <example>
|
||||
* $translatedObj = DataObject::get_one_by_lang('MyObject', 'de');
|
||||
* $translatedObj = DataObject::get_one_by_locale('MyObject', 'de_DE');
|
||||
* </example>
|
||||
*
|
||||
* Getting a translation for an existing instance:
|
||||
* <example>
|
||||
* $obj = DataObject::get_by_id('MyObject', 99); // original language
|
||||
* $translatedObj = $obj->getTranslation('de');
|
||||
* $translatedObj = $obj->getTranslation('de_DE');
|
||||
* </example>
|
||||
*
|
||||
* Getting translations through {@link Translatable::set_reading_lang()}.
|
||||
* Getting translations through {@link Translatable::set_reading_locale()}.
|
||||
* This is *not* a recommended approach, but sometimes inavoidable (e.g. for {@link Versioned} methods).
|
||||
* <example>
|
||||
* $obj = DataObject::get_by_id('MyObject', 99); // original language
|
||||
* $translatedObj = $obj->getTranslation('de');
|
||||
* $translatedObj = $obj->getTranslation('de_DE');
|
||||
* </example>
|
||||
*
|
||||
* Creating a translation:
|
||||
* <example>
|
||||
* $obj = new MyObject();
|
||||
* $translatedObj = $obj->createTranslation('de');
|
||||
* $translatedObj = $obj->createTranslation('de_DE');
|
||||
* </example>
|
||||
*
|
||||
* <h2>Usage for SiteTree</h2>
|
||||
@ -55,7 +55,7 @@
|
||||
* languages by auto-appending the language code at the end.
|
||||
* You'll need to ensure that the appropriate "reading language" is set
|
||||
* before showing links to other pages on a website: Either
|
||||
* through setting $_COOKIE['lang'], $_SESSION['lang'] or $_GET['lang'].
|
||||
* through setting $_COOKIE['locale'], $_SESSION['locale'] or $_GET['locale'].
|
||||
* Pages in different languages can have different publication states
|
||||
* through the {@link Versioned} extension.
|
||||
*
|
||||
@ -93,14 +93,14 @@
|
||||
* Important: If the "default language" of your site is not english (en_US),
|
||||
* please ensure to set the appropriate default language for
|
||||
* your content before building the database with Translatable enabled:
|
||||
* Translatable::set_default_language(<locale>);
|
||||
* Translatable::set_default_locale(<locale>);
|
||||
*
|
||||
* <h2>Uninstalling/Disabling</h2>
|
||||
*
|
||||
* Disabling Translatable after creating translations will lead to all
|
||||
* pages being shown in the default sitetree regardless of their language.
|
||||
* It is advised to start with a new database after uninstalling Translatable,
|
||||
* or manually filter out translated objects through their "Lang" property
|
||||
* or manually filter out translated objects through their "Locale" property
|
||||
* in the database.
|
||||
*
|
||||
* @author Michael Gall <michael (at) wakeless (dot) net>
|
||||
@ -123,7 +123,7 @@ class Translatable extends DataObjectDecorator {
|
||||
* The 'default' language.
|
||||
* @var string
|
||||
*/
|
||||
protected static $default_lang = 'en';
|
||||
protected static $default_locale = 'en_US';
|
||||
|
||||
/**
|
||||
* The language in which we are reading dataobjects.
|
||||
@ -132,7 +132,7 @@ class Translatable extends DataObjectDecorator {
|
||||
* @see Director::get_site_mode()
|
||||
* @var string
|
||||
*/
|
||||
protected static $reading_lang = null;
|
||||
protected static $reading_locale = null;
|
||||
|
||||
/**
|
||||
* Indicates if the start language has been determined using choose_site_lang
|
||||
@ -141,7 +141,7 @@ class Translatable extends DataObjectDecorator {
|
||||
protected static $language_decided = false;
|
||||
|
||||
/**
|
||||
* Indicates whether the 'Lang' transformation when modifying queries should be bypassed
|
||||
* Indicates whether the 'Locale' transformation when modifying queries should be bypassed
|
||||
* If it's true
|
||||
*
|
||||
* @var boolean
|
||||
@ -175,7 +175,7 @@ class Translatable extends DataObjectDecorator {
|
||||
protected $original_values = null;
|
||||
|
||||
/**
|
||||
* @var boolean Temporarily override the "auto-filter" for {@link current_lang()}
|
||||
* @var boolean Temporarily override the "auto-filter" for {@link current_locale()}
|
||||
* in {@link augmentSQL()}. IMPORTANT: You must set this value back to TRUE
|
||||
* after the temporary usage.
|
||||
*/
|
||||
@ -183,7 +183,7 @@ class Translatable extends DataObjectDecorator {
|
||||
|
||||
/**
|
||||
* Choose the language the site is currently on.
|
||||
* If $_GET['lang'] or $_COOKIE['lang'] is set, then it will use that language, and store it in the session.
|
||||
* If $_GET['locale'] or $_COOKIE['locale'] is set, then it will use that language, and store it in the session.
|
||||
* Otherwise it checks the session for a possible stored language, either from namespace to the site_mode
|
||||
* ('site' or 'cms'), or for a 'global' language setting.
|
||||
* The final option is the member preference.
|
||||
@ -192,25 +192,25 @@ class Translatable extends DataObjectDecorator {
|
||||
*
|
||||
* @uses Director::get_site_mode()
|
||||
* @param $langsAvailable array A numerical array of languages which are valid choices (optional)
|
||||
* @return string Selected language (also saved in $reading_lang).
|
||||
* @return string Selected language (also saved in $reading_locale).
|
||||
*/
|
||||
static function choose_site_lang($langsAvailable = array()) {
|
||||
$siteMode = Director::get_site_mode(); // either 'cms' or 'site'
|
||||
if(self::$reading_lang) {
|
||||
if(self::$reading_locale) {
|
||||
self::$language_decided = true;
|
||||
return self::$reading_lang;
|
||||
return self::$reading_locale;
|
||||
}
|
||||
|
||||
if((isset($_GET['lang']) && !$langsAvailable) || (isset($_GET['lang']) && in_array($_GET['lang'], $langsAvailable))) {
|
||||
if((isset($_GET['locale']) && !$langsAvailable) || (isset($_GET['locale']) && in_array($_GET['locale'], $langsAvailable))) {
|
||||
// get from GET parameter
|
||||
self::set_reading_lang($_GET['lang']);
|
||||
self::set_reading_locale($_GET['locale']);
|
||||
} else {
|
||||
self::set_reading_lang(self::default_lang());
|
||||
self::set_reading_locale(self::default_locale());
|
||||
}
|
||||
|
||||
|
||||
self::$language_decided = true;
|
||||
return self::$reading_lang;
|
||||
return self::$reading_locale;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -220,34 +220,34 @@ class Translatable extends DataObjectDecorator {
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
static function default_lang() {
|
||||
return self::$default_lang;
|
||||
static function default_locale() {
|
||||
return self::$default_locale;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set default language.
|
||||
*
|
||||
* @param $lang String
|
||||
* @param $locale String
|
||||
*/
|
||||
static function set_default_lang($lang) {
|
||||
self::$default_lang = $lang;
|
||||
static function set_default_locale($locale) {
|
||||
self::$default_locale = $locale;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the default and current reading language are the same.
|
||||
* @return boolean Return true if both default and reading language are the same.
|
||||
*/
|
||||
static function is_default_lang() {
|
||||
return (!self::current_lang() || self::$default_lang == self::current_lang());
|
||||
static function is_default_locale() {
|
||||
return (!self::current_locale() || self::$default_locale == self::current_locale());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current reading language.
|
||||
* @return string
|
||||
*/
|
||||
static function current_lang() {
|
||||
static function current_locale() {
|
||||
if (!self::$language_decided) self::choose_site_lang();
|
||||
return self::$reading_lang;
|
||||
return self::$reading_locale;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -258,25 +258,25 @@ class Translatable extends DataObjectDecorator {
|
||||
*
|
||||
* @param string $lang New reading language.
|
||||
*/
|
||||
static function set_reading_lang($lang) {
|
||||
self::$reading_lang = $lang;
|
||||
static function set_reading_locale($locale) {
|
||||
self::$reading_locale = $locale;
|
||||
self::$language_decided = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a singleton instance of a class in the given language.
|
||||
* @param string $class The name of the class.
|
||||
* @param string $lang The name of the language.
|
||||
* @param string $locale The name of the language.
|
||||
* @param string $filter A filter to be inserted into the WHERE clause.
|
||||
* @param boolean $cache Use caching (default: false)
|
||||
* @param string $orderby A sort expression to be inserted into the ORDER BY clause.
|
||||
* @return DataObject
|
||||
*/
|
||||
static function get_one_by_lang($class, $lang, $filter = '', $cache = false, $orderby = "") {
|
||||
$orig = Translatable::current_lang();
|
||||
Translatable::set_reading_lang($lang);
|
||||
static function get_one_by_locale($class, $locale, $filter = '', $cache = false, $orderby = "") {
|
||||
$orig = Translatable::current_locale();
|
||||
Translatable::set_reading_locale($locale);
|
||||
$do = DataObject::get_one($class, $filter, $cache, $orderby);
|
||||
Translatable::set_reading_lang($orig);
|
||||
Translatable::set_reading_locale($orig);
|
||||
return $do;
|
||||
}
|
||||
|
||||
@ -284,7 +284,7 @@ class Translatable extends DataObjectDecorator {
|
||||
* Get all the instances of the given class translated to the given language
|
||||
*
|
||||
* @param string $class The name of the class
|
||||
* @param string $lang The name of the language
|
||||
* @param string $locale The name of the language
|
||||
* @param string $filter A filter to be inserted into the WHERE clause.
|
||||
* @param string $sort A sort expression to be inserted into the ORDER BY clause.
|
||||
* @param string $join A single join clause. This can be used for filtering, only 1 instance of each DataObject will be returned.
|
||||
@ -293,26 +293,14 @@ class Translatable extends DataObjectDecorator {
|
||||
* @param string $having A filter to be inserted into the HAVING clause.
|
||||
* @return mixed The objects matching the conditions.
|
||||
*/
|
||||
static function get_by_lang($class, $lang, $filter = '', $sort = '', $join = "", $limit = "", $containerClass = "DataObjectSet", $having = "") {
|
||||
$oldLang = self::current_lang();
|
||||
self::set_reading_lang($lang);
|
||||
static function get_by_locale($class, $locale, $filter = '', $sort = '', $join = "", $limit = "", $containerClass = "DataObjectSet", $having = "") {
|
||||
$oldLang = self::current_locale();
|
||||
self::set_reading_locale($locale);
|
||||
$result = DataObject::get($class, $filter, $sort, $join, $limit, $containerClass, $having);
|
||||
self::set_reading_lang($oldLang);
|
||||
self::set_reading_locale($oldLang);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a record in his original language version.
|
||||
* @param string $class The name of the class.
|
||||
* @param string $originalLangID The original record id.
|
||||
* @return DataObject
|
||||
*/
|
||||
static function get_original($class, $originalLangID) {
|
||||
$baseClass = $class;
|
||||
while( ($p = get_parent_class($baseClass)) != "DataObject") $baseClass = $p;
|
||||
return self::get_one_by_lang($class,self::default_lang(),"\"$baseClass\".\"ID\" = $originalLangID");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all translations for this specific page.
|
||||
* Doesn't include the language of the current record.
|
||||
@ -331,7 +319,7 @@ class Translatable extends DataObjectDecorator {
|
||||
$translationGroupID = $this->owner->getTranslationGroup();
|
||||
if(is_numeric($translationGroupID)) {
|
||||
$query = new SQLQuery(
|
||||
'DISTINCT Lang',
|
||||
'DISTINCT Locale',
|
||||
sprintf(
|
||||
'"%s" LEFT JOIN "%s" ON "%s"."OriginalID" = "%s"."ID"',
|
||||
$baseDataClass,
|
||||
@ -340,11 +328,11 @@ class Translatable extends DataObjectDecorator {
|
||||
$baseDataClass
|
||||
), // from
|
||||
sprintf(
|
||||
'"%s"."TranslationGroupID" = %d AND "%s"."Lang" != \'%s\'',
|
||||
'"%s"."TranslationGroupID" = %d AND "%s"."Locale" != \'%s\'',
|
||||
$translationGroupClass,
|
||||
$translationGroupID,
|
||||
$baseDataClass,
|
||||
$this->owner->Lang
|
||||
$this->owner->Locale
|
||||
) // where
|
||||
);
|
||||
$langs = $query->execute()->column();
|
||||
@ -445,11 +433,11 @@ class Translatable extends DataObjectDecorator {
|
||||
if(get_class($this->owner) == ClassInfo::baseDataClass(get_class($this->owner))) {
|
||||
return array(
|
||||
"db" => array(
|
||||
"Lang" => "Varchar(12)",
|
||||
"Locale" => "Varchar(12)",
|
||||
"TranslationMasterID" => "Int" // optional relation to a "translation master"
|
||||
),
|
||||
"defaults" => array(
|
||||
"Lang" => Translatable::default_lang() // as an overloaded getter as well: getLang()
|
||||
"Locale" => Translatable::default_locale() // as an overloaded getter as well: getLang()
|
||||
)
|
||||
);
|
||||
} else {
|
||||
@ -459,8 +447,8 @@ class Translatable extends DataObjectDecorator {
|
||||
|
||||
/**
|
||||
* Changes any SELECT query thats not filtering on an ID
|
||||
* to limit by the current language defined in {@link current_lang()}.
|
||||
* It falls back to "Lang='' OR Lang IS NULL" and assumes that
|
||||
* to limit by the current language defined in {@link current_locale()}.
|
||||
* It falls back to "Locale='' OR Lang IS NULL" and assumes that
|
||||
* this implies querying for the default language.
|
||||
*
|
||||
* Use {@link $enable_lang_filter} to temporarily disable this "auto-filtering".
|
||||
@ -468,7 +456,7 @@ class Translatable extends DataObjectDecorator {
|
||||
function augmentSQL(SQLQuery &$query) {
|
||||
if(!Translatable::is_enabled()) return;
|
||||
|
||||
$lang = Translatable::current_lang();
|
||||
$lang = Translatable::current_locale();
|
||||
$baseTable = ClassInfo::baseDataClass($this->owner->class);
|
||||
$where = $query->where;
|
||||
if(
|
||||
@ -484,10 +472,10 @@ class Translatable extends DataObjectDecorator {
|
||||
&& !preg_match('/("|\')Lang("|\')/', $query->getFilter())
|
||||
//&& !$query->filtersOnFK()
|
||||
) {
|
||||
$qry = "\"Lang\" = '$lang'";
|
||||
if(Translatable::is_default_lang()) {
|
||||
$qry .= " OR \"Lang\" = '' ";
|
||||
$qry .= " OR \"Lang\" IS NULL ";
|
||||
$qry = "\"Locale\" = '$lang'";
|
||||
if(Translatable::is_default_locale()) {
|
||||
$qry .= " OR \"Locale\" = '' ";
|
||||
$qry .= " OR \"Locale\" IS NULL ";
|
||||
}
|
||||
$query->where[] = $qry;
|
||||
}
|
||||
@ -592,7 +580,7 @@ class Translatable extends DataObjectDecorator {
|
||||
function contentcontrollerInit($controller) {
|
||||
if(!Translatable::is_enabled()) return;
|
||||
Translatable::choose_site_lang();
|
||||
$controller->Lang = Translatable::current_lang();
|
||||
$controller->Locale = Translatable::current_locale();
|
||||
}
|
||||
|
||||
function modelascontrollerInit($controller) {
|
||||
@ -617,12 +605,12 @@ class Translatable extends DataObjectDecorator {
|
||||
function onBeforeWrite() {
|
||||
if(!Translatable::is_enabled()) return;
|
||||
|
||||
// If language is not set explicitly, set it to current_lang.
|
||||
// If language is not set explicitly, set it to current_locale.
|
||||
// This might be a bit overzealous in assuming the language
|
||||
// of the content, as a "single language" website might be expanded
|
||||
// later on.
|
||||
if(!$this->owner->ID && !$this->owner->Lang) {
|
||||
$this->owner->Lang = Translatable::current_lang();
|
||||
if(!$this->owner->ID && !$this->owner->Locale) {
|
||||
$this->owner->Locale = Translatable::current_locale();
|
||||
}
|
||||
|
||||
// Specific logic for SiteTree subclasses.
|
||||
@ -633,9 +621,9 @@ class Translatable extends DataObjectDecorator {
|
||||
if(
|
||||
!$this->owner->ID
|
||||
&& $this->owner->ParentID
|
||||
&& !$this->owner->Parent()->hasTranslation($this->owner->Lang)
|
||||
&& !$this->owner->Parent()->hasTranslation($this->owner->Locale)
|
||||
) {
|
||||
$parentTranslation = $this->owner->Parent()->createTranslation($this->owner->Lang);
|
||||
$parentTranslation = $this->owner->Parent()->createTranslation($this->owner->Locale);
|
||||
$this->owner->ParentID = $parentTranslation->ID;
|
||||
}
|
||||
}
|
||||
@ -645,10 +633,10 @@ class Translatable extends DataObjectDecorator {
|
||||
// will save as "myfrenchpage-fr" (only if we're not in the "default language").
|
||||
// Its bad SEO to have multiple resources with different content (=language) under the same URL.
|
||||
if($this->owner->hasField('URLSegment')) {
|
||||
if(!$this->owner->ID && $this->owner->Lang != Translatable::default_lang()) {
|
||||
if(!$this->owner->ID && $this->owner->Locale != Translatable::default_locale()) {
|
||||
$SQL_URLSegment = Convert::raw2sql($this->owner->URLSegment);
|
||||
$existingOriginalPage = Translatable::get_one_by_lang('SiteTree', Translatable::default_lang(), "\"URLSegment\" = '{$SQL_URLSegment}'");
|
||||
if($existingOriginalPage) $this->owner->URLSegment .= "-{$this->owner->Lang}";
|
||||
$existingOriginalPage = Translatable::get_one_by_lang('SiteTree', Translatable::default_locale(), "\"URLSegment\" = '{$SQL_URLSegment}'");
|
||||
if($existingOriginalPage) $this->owner->URLSegment .= "-{$this->owner->Locale}";
|
||||
}
|
||||
}
|
||||
|
||||
@ -733,7 +721,7 @@ class Translatable extends DataObjectDecorator {
|
||||
if(!($this->owner instanceof SiteTree)) return;
|
||||
|
||||
// used in CMSMain->init() to set language state when reading/writing record
|
||||
$fields->push(new HiddenField("Lang", "Lang", $this->owner->Lang) );
|
||||
$fields->push(new HiddenField("Locale", "Locale", $this->owner->Locale) );
|
||||
|
||||
// if a language other than default language is used, we're in "translation mode",
|
||||
// hence have to modify the original fields
|
||||
@ -743,14 +731,14 @@ class Translatable extends DataObjectDecorator {
|
||||
while( ($p = get_parent_class($baseClass)) != "DataObject") $baseClass = $p;
|
||||
|
||||
// try to get the record in "default language"
|
||||
$originalRecord = $this->owner->getTranslation(Translatable::default_lang());
|
||||
$originalRecord = $this->owner->getTranslation(Translatable::default_locale());
|
||||
// if no translation in "default language", fall back to first translation
|
||||
if(!$originalRecord) {
|
||||
$translations = $this->owner->getTranslations();
|
||||
$originalRecord = ($translations) ? $translations->First() : null;
|
||||
}
|
||||
|
||||
$isTranslationMode = $this->owner->Lang != Translatable::default_lang();
|
||||
$isTranslationMode = $this->owner->Locale != Translatable::default_locale();
|
||||
|
||||
if($originalRecord && $isTranslationMode) {
|
||||
$originalLangID = Session::get($this->owner->ID . '_originalLangID');
|
||||
@ -794,11 +782,11 @@ class Translatable extends DataObjectDecorator {
|
||||
// We'd still want to show the default lang though,
|
||||
// as records in this language might have NULL values in their $Lang property
|
||||
// and otherwise wouldn't show up here
|
||||
//$alreadyTranslatedLangs[Translatable::default_lang()] = i18n::get_language_name(Translatable::default_lang());
|
||||
//$alreadyTranslatedLangs[Translatable::default_locale()] = i18n::get_locale_name(Translatable::default_locale());
|
||||
|
||||
// Exclude the current language from being shown.
|
||||
if(Translatable::current_lang() != Translatable::default_lang()) {
|
||||
$currentLangKey = array_search(Translatable::current_lang(), $alreadyTranslatedLangs);
|
||||
if(Translatable::current_locale() != Translatable::default_locale()) {
|
||||
$currentLangKey = array_search(Translatable::current_locale(), $alreadyTranslatedLangs);
|
||||
if($currentLangKey) unset($alreadyTranslatedLangs[$currentLangKey]);
|
||||
}
|
||||
|
||||
@ -806,7 +794,13 @@ class Translatable extends DataObjectDecorator {
|
||||
'Root',
|
||||
new Tab(_t('Translatable.TRANSLATIONS', 'Translations'),
|
||||
new HeaderField('CreateTransHeader', _t('Translatable.CREATE', 'Create new translation'), 2),
|
||||
$langDropdown = new LanguageDropdownField("NewTransLang", _t('Translatable.NEWLANGUAGE', 'New language'), $alreadyTranslatedLangs),
|
||||
$langDropdown = new LanguageDropdownField(
|
||||
"NewTransLang",
|
||||
_t('Translatable.NEWLANGUAGE', 'New language'),
|
||||
$alreadyTranslatedLangs,
|
||||
'SiteTree',
|
||||
'Locale-English'
|
||||
),
|
||||
$createButton = new InlineFormAction('createtranslation',_t('Translatable.CREATEBUTTON', 'Create'))
|
||||
)
|
||||
);
|
||||
@ -822,8 +816,8 @@ class Translatable extends DataObjectDecorator {
|
||||
$existingTranslation = $this->owner->getTranslation($langCode);
|
||||
if($existingTranslation) {
|
||||
$existingTransHTML .= sprintf('<li><a href="%s">%s</a></li>',
|
||||
sprintf('admin/show/%d/?lang=%s', $existingTranslation->ID, $langCode),
|
||||
i18n::get_language_name($langCode)
|
||||
sprintf('admin/show/%d/?locale=%s', $existingTranslation->ID, $langCode),
|
||||
i18n::get_locale_name($langCode)
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -879,10 +873,10 @@ class Translatable extends DataObjectDecorator {
|
||||
* excluding itself. See {@link getTranslation()} to retrieve
|
||||
* a single translated object.
|
||||
*
|
||||
* @param string $lang
|
||||
* @param string $locale
|
||||
* @return DataObjectSet
|
||||
*/
|
||||
function getTranslations($lang = null) {
|
||||
function getTranslations($locale = null) {
|
||||
if($this->owner->exists()) {
|
||||
// HACK need to disable language filtering in augmentSQL(),
|
||||
// as we purposely want to get different language
|
||||
@ -892,11 +886,11 @@ class Translatable extends DataObjectDecorator {
|
||||
|
||||
$baseDataClass = ClassInfo::baseDataClass($this->owner->class);
|
||||
$filter = sprintf('"%s_translationgroups"."TranslationGroupID" = %d', $baseDataClass, $translationGroupID);
|
||||
if($lang) {
|
||||
$filter .= sprintf(' AND "%s"."Lang" = \'%s\'', $baseDataClass, Convert::raw2sql($lang));
|
||||
if($locale) {
|
||||
$filter .= sprintf(' AND "%s"."Locale" = \'%s\'', $baseDataClass, Convert::raw2sql($locale));
|
||||
} else {
|
||||
// exclude the language of the current owner
|
||||
$filter .= sprintf(' AND "%s"."Lang" != \'%s\'', $baseDataClass, $this->owner->Lang);
|
||||
$filter .= sprintf(' AND "%s"."Locale" != \'%s\'', $baseDataClass, $this->owner->Locale);
|
||||
}
|
||||
$join = sprintf('LEFT JOIN "%s_translationgroups" ON "%s_translationgroups"."OriginalID" = "%s"."ID"',
|
||||
$baseDataClass,
|
||||
@ -921,11 +915,11 @@ class Translatable extends DataObjectDecorator {
|
||||
* Use {@link hasTranslation()} as a quicker alternative to check
|
||||
* for an existing translation without getting the actual object.
|
||||
*
|
||||
* @param String $lang
|
||||
* @param String $locale
|
||||
* @return DataObject Translated object
|
||||
*/
|
||||
function getTranslation($lang) {
|
||||
$translations = $this->getTranslations($lang);
|
||||
function getTranslation($locale) {
|
||||
$translations = $this->getTranslations($locale);
|
||||
return ($translations) ? $translations->First() : null;
|
||||
}
|
||||
|
||||
@ -938,15 +932,15 @@ class Translatable extends DataObjectDecorator {
|
||||
* it belongs to. For "original records" which are not created through this
|
||||
* method, the "translation group" is set in {@link onAfterWrite()}.
|
||||
*
|
||||
* @param string $lang
|
||||
* @param string $locale
|
||||
* @return DataObject The translated object
|
||||
*/
|
||||
function createTranslation($lang) {
|
||||
function createTranslation($locale) {
|
||||
if(!$this->owner->exists()) {
|
||||
user_error('Translatable::createTranslation(): Please save your record before creating a translation', E_USER_ERROR);
|
||||
}
|
||||
|
||||
$existingTranslation = $this->getTranslation($lang);
|
||||
$existingTranslation = $this->getTranslation($locale);
|
||||
if($existingTranslation) return $existingTranslation;
|
||||
|
||||
$class = $this->owner->class;
|
||||
@ -954,7 +948,7 @@ class Translatable extends DataObjectDecorator {
|
||||
// copy all fields from owner (apart from ID)
|
||||
$newTranslation->update($this->owner->toMap());
|
||||
$newTranslation->ID = 0;
|
||||
$newTranslation->Lang = $lang;
|
||||
$newTranslation->Locale = $locale;
|
||||
// hacky way to set an existing translation group in onAfterWrite()
|
||||
$translationGroupID = $this->owner->getTranslationGroup();
|
||||
$newTranslation->_TranslationGroupID = $translationGroupID ? $translationGroupID : $this->owner->ID;
|
||||
@ -968,10 +962,11 @@ class Translatable extends DataObjectDecorator {
|
||||
* Use {@link getTranslation()} to get the actual translated record from
|
||||
* the database.
|
||||
*
|
||||
* @param string $locale
|
||||
* @return boolean
|
||||
*/
|
||||
function hasTranslation($lang) {
|
||||
return (array_search($lang, $this->getTranslatedLangs()) !== false);
|
||||
function hasTranslation($locale) {
|
||||
return (array_search($locale, $this->getTranslatedLangs()) !== false);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1007,12 +1002,12 @@ class Translatable extends DataObjectDecorator {
|
||||
$find = array();
|
||||
$replace = array();
|
||||
|
||||
if($context && $context->Lang && $context->Lang != Translatable::default_lang()) {
|
||||
if($context && $context->Locale && $context->Locale != Translatable::default_locale()) {
|
||||
|
||||
if($children) {
|
||||
foreach($children as $child) {
|
||||
if($child->hasTranslation($context->Lang)) {
|
||||
$trans = $child->getTranslation($context->Lang);
|
||||
if($child->hasTranslation($context->Locale)) {
|
||||
$trans = $child->getTranslation($context->Locale);
|
||||
if($trans) {
|
||||
$find[] = $child;
|
||||
$replace[] = $trans;
|
||||
@ -1032,16 +1027,16 @@ class Translatable extends DataObjectDecorator {
|
||||
* Get a list of languages with at least one element translated in (including the default language)
|
||||
*
|
||||
* @param string $className Look for languages in elements of this class
|
||||
* @return array Map of languages in the form langCode => langName
|
||||
* @return array Map of languages in the form locale => langName
|
||||
*/
|
||||
static function get_existing_content_languages($className = 'SiteTree', $where = '') {
|
||||
if(!Translatable::is_enabled()) return false;
|
||||
$baseTable = ClassInfo::baseDataClass($className);
|
||||
$query = new SQLQuery('Distinct Lang',$baseTable,$where,"",'Lang');
|
||||
$query = new SQLQuery('Distinct Locale',$baseTable,$where,"",'Locale');
|
||||
$dbLangs = $query->execute()->column();
|
||||
$langlist = array_merge((array)Translatable::default_lang(), (array)$dbLangs);
|
||||
$langlist = array_merge((array)Translatable::default_locale(), (array)$dbLangs);
|
||||
$returnMap = array();
|
||||
$allCodes = array_merge(i18n::$all_locales, i18n::$common_languages);
|
||||
$allCodes = array_merge(i18n::$all_locales, i18n::$common_locales);
|
||||
foreach ($langlist as $langCode) {
|
||||
if($langCode)
|
||||
$returnMap[$langCode] = (is_array($allCodes[$langCode]) ? $allCodes[$langCode][0] : $allCodes[$langCode]);
|
||||
@ -1055,17 +1050,17 @@ class Translatable extends DataObjectDecorator {
|
||||
* (as identified by RootURLController::$default_homepage_urlsegment).
|
||||
* Returns NULL if no translated page can be found.
|
||||
*
|
||||
* @param string $Lang
|
||||
* @param string $locale
|
||||
* @return string|boolean URLSegment (e.g. "home")
|
||||
*/
|
||||
static function get_homepage_urlsegment_by_language($lang) {
|
||||
$origHomepageObj = Translatable::get_one_by_lang(
|
||||
static function get_homepage_urlsegment_by_language($locale) {
|
||||
$origHomepageObj = Translatable::get_one_by_locale(
|
||||
'SiteTree',
|
||||
Translatable::default_lang(),
|
||||
Translatable::default_locale(),
|
||||
sprintf('"URLSegment" = \'%s\'', RootUrlController::get_default_homepage_urlsegment())
|
||||
);
|
||||
if($origHomepageObj) {
|
||||
$translatedHomepageObj = $origHomepageObj->getTranslation(Translatable::current_lang());
|
||||
$translatedHomepageObj = $origHomepageObj->getTranslation(Translatable::current_locale());
|
||||
if($translatedHomepageObj) {
|
||||
return $translatedHomepageObj->URLSegment;
|
||||
}
|
||||
@ -1073,6 +1068,62 @@ class Translatable extends DataObjectDecorator {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 2.4 Use is_default_locale()
|
||||
*/
|
||||
static function is_default_lang() {
|
||||
return self::is_default_locale();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 2.4 Use set_default_locale()
|
||||
*/
|
||||
static function set_default_lang($lang) {
|
||||
self::set_default_locale($lang);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 2.4 Use get_default_locale()
|
||||
*/
|
||||
static function get_default_lang() {
|
||||
return self::get_default_locale();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 2.4 Use current_locale()
|
||||
*/
|
||||
static function current_lang() {
|
||||
return self::current_locale();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 2.4 Use set_reading_locale()
|
||||
*/
|
||||
static function set_reading_lang($lang) {
|
||||
self::set_reading_locale($lang);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 2.4 Use get_reading_locale()
|
||||
*/
|
||||
static function get_reading_lang() {
|
||||
return self::get_reading_locale();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 2.4 Use get_by_locale()
|
||||
*/
|
||||
static function get_by_lang($class, $lang, $filter = '', $sort = '', $join = "", $limit = "", $containerClass = "DataObjectSet", $having = "") {
|
||||
return self::get_by_locale($class, $lang, $filter, $sort, $join, $limit, $containerClass, $having);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 2.4 Use get_one_by_locale()
|
||||
*/
|
||||
static function get_one_by_lang($class, $lang, $filter = '', $cache = false, $orderby = "") {
|
||||
return self::get_one_by_locale($class, $lang, $filter, $cache, $orderby);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -255,7 +255,7 @@ class Debug {
|
||||
if(Director::is_ajax()) {
|
||||
echo $friendlyErrorMessage;
|
||||
} else {
|
||||
$errorFilePath = ErrorPage::get_filepath_for_errorcode($statusCode, Translatable::current_lang());
|
||||
$errorFilePath = ErrorPage::get_filepath_for_errorcode($statusCode, Translatable::current_locale());
|
||||
if(file_exists($errorfilePath)) {
|
||||
echo file_get_contents(ASSETS_PATH . "/error-$statusCode.html");
|
||||
} else {
|
||||
|
@ -6,7 +6,7 @@
|
||||
* If multilingual content is enabled through the {@link Translatable} extension,
|
||||
* only pages the currently set language on the holder for this searchform are found.
|
||||
* The language is set through a hidden field in the form, which is prepoluated
|
||||
* with {@link Translatable::current_lang()} when then form is constructed.
|
||||
* with {@link Translatable::current_locale()} when then form is constructed.
|
||||
*
|
||||
* @see Use ModelController and SearchContext for a more generic search implementation based around DataObject
|
||||
* @package sapphire
|
||||
@ -55,7 +55,7 @@ class SearchForm extends Form {
|
||||
}
|
||||
|
||||
if(Translatable::is_enabled()) {
|
||||
$fields->push(new HiddenField('lang', 'lang', Translatable::current_lang()));
|
||||
$fields->push(new HiddenField('lang', 'lang', Translatable::current_locale()));
|
||||
}
|
||||
|
||||
if(!$actions) {
|
||||
@ -105,7 +105,7 @@ class SearchForm extends Form {
|
||||
|
||||
// set language (if present)
|
||||
if(Translatable::is_enabled() && isset($data['lang'])) {
|
||||
Translatable::set_reading_lang($data['lang']);
|
||||
Translatable::set_reading_locale($data['lang']);
|
||||
}
|
||||
|
||||
$keywords = $data['Search'];
|
||||
|
@ -35,7 +35,8 @@ class MigrateTranslatableTask extends BuildTask {
|
||||
// Clone the original, and set it up as a translation
|
||||
$newtrans = $original->duplicate(false);
|
||||
$newtrans->OriginalID = $original->ID;
|
||||
$newtrans->Lang = $oldtrans['Lang'];
|
||||
// we have to "guess" a locale based on the language
|
||||
$newtrans->Locale = i18n::get_locale_from_lang($oldtrans['Lang']);
|
||||
if($stage == 'Live' && array_key_exists($original->ID, $ids)) {
|
||||
$newtrans->ID = $ids[$original->ID];
|
||||
}
|
||||
@ -53,7 +54,7 @@ class MigrateTranslatableTask extends BuildTask {
|
||||
|
||||
// Copy each translated field into the new translation
|
||||
if($oldtransitem) foreach($oldtransitem as $key => $value) {
|
||||
if(!in_array($key, array('ID', 'OriginalLangID', 'ClassName', 'Lang'))) {
|
||||
if(!in_array($key, array('ID', 'OriginalLangID', 'ClassName'))) {
|
||||
$newtrans->$key = $value;
|
||||
}
|
||||
}
|
||||
@ -62,10 +63,10 @@ class MigrateTranslatableTask extends BuildTask {
|
||||
|
||||
|
||||
// Write the new translation to the database
|
||||
$sitelang = Translatable::current_lang();
|
||||
Translatable::set_reading_lang($newtrans->Lang);
|
||||
$sitelang = Translatable::current_locale();
|
||||
Translatable::set_reading_locale($newtrans->Locale);
|
||||
$newtrans->writeToStage($stage, true);
|
||||
Translatable::set_reading_lang($sitelang);
|
||||
Translatable::set_reading_locale($sitelang);
|
||||
|
||||
if($stage == 'Stage') {
|
||||
$ids[$original->ID] = $newtrans->ID;
|
||||
@ -79,4 +80,4 @@ class MigrateTranslatableTask extends BuildTask {
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
@ -16,9 +16,9 @@ class TranslatableTest extends FunctionalTest {
|
||||
|
||||
function setUp() {
|
||||
$this->origTranslatableSettings['enabled'] = Translatable::is_enabled();
|
||||
$this->origTranslatableSettings['default_lang'] = Translatable::default_lang();
|
||||
$this->origTranslatableSettings['default_locale'] = Translatable::default_locale();
|
||||
Translatable::enable();
|
||||
Translatable::set_default_lang("en");
|
||||
Translatable::set_default_locale("en_US");
|
||||
|
||||
// needs to recreate the database schema with language properties
|
||||
self::kill_temp_db();
|
||||
@ -34,7 +34,7 @@ class TranslatableTest extends FunctionalTest {
|
||||
function tearDown() {
|
||||
if(!$this->origTranslatableSettings['enabled']) Translatable::disable();
|
||||
|
||||
Translatable::set_default_lang($this->origTranslatableSettings['default_lang']);
|
||||
Translatable::set_default_locale($this->origTranslatableSettings['default_locale']);
|
||||
|
||||
self::kill_temp_db();
|
||||
self::create_temp_db();
|
||||
@ -45,68 +45,68 @@ class TranslatableTest extends FunctionalTest {
|
||||
function testTranslationGroups() {
|
||||
// first in french
|
||||
$frPage = new SiteTree();
|
||||
$frPage->Lang = 'fr';
|
||||
$frPage->Locale = 'fr_FR';
|
||||
$frPage->write();
|
||||
|
||||
// second in english (from french "original")
|
||||
$enPage = $frPage->createTranslation('en');
|
||||
$enPage = $frPage->createTranslation('en_US');
|
||||
|
||||
// third in spanish (from the english translation)
|
||||
$esPage = $enPage->createTranslation('es');
|
||||
$esPage = $enPage->createTranslation('es_ES');
|
||||
|
||||
// test french
|
||||
$this->assertEquals(
|
||||
$frPage->getTranslations()->column('Lang'),
|
||||
array('en','es')
|
||||
$frPage->getTranslations()->column('Locale'),
|
||||
array('en_US','es_ES')
|
||||
);
|
||||
$this->assertNotNull($frPage->getTranslation('en'));
|
||||
$this->assertNotNull($frPage->getTranslation('en_US'));
|
||||
$this->assertEquals(
|
||||
$frPage->getTranslation('en')->ID,
|
||||
$frPage->getTranslation('en_US')->ID,
|
||||
$enPage->ID
|
||||
);
|
||||
$this->assertNotNull($frPage->getTranslation('es'));
|
||||
$this->assertNotNull($frPage->getTranslation('es_ES'));
|
||||
$this->assertEquals(
|
||||
$frPage->getTranslation('es')->ID,
|
||||
$frPage->getTranslation('es_ES')->ID,
|
||||
$esPage->ID
|
||||
);
|
||||
|
||||
// test english
|
||||
$this->assertEquals(
|
||||
$enPage->getTranslations()->column('Lang'),
|
||||
array('fr','es')
|
||||
$enPage->getTranslations()->column('Locale'),
|
||||
array('fr_FR','es_ES')
|
||||
);
|
||||
$this->assertNotNull($frPage->getTranslation('fr'));
|
||||
$this->assertNotNull($frPage->getTranslation('fr_FR'));
|
||||
$this->assertEquals(
|
||||
$enPage->getTranslation('fr')->ID,
|
||||
$enPage->getTranslation('fr_FR')->ID,
|
||||
$frPage->ID
|
||||
);
|
||||
$this->assertNotNull($frPage->getTranslation('es'));
|
||||
$this->assertNotNull($frPage->getTranslation('es_ES'));
|
||||
$this->assertEquals(
|
||||
$enPage->getTranslation('es')->ID,
|
||||
$enPage->getTranslation('es_ES')->ID,
|
||||
$esPage->ID
|
||||
);
|
||||
|
||||
// test spanish
|
||||
$this->assertEquals(
|
||||
$esPage->getTranslations()->column('Lang'),
|
||||
array('fr','en')
|
||||
$esPage->getTranslations()->column('Locale'),
|
||||
array('fr_FR','en_US')
|
||||
);
|
||||
$this->assertNotNull($esPage->getTranslation('fr'));
|
||||
$this->assertNotNull($esPage->getTranslation('fr_FR'));
|
||||
$this->assertEquals(
|
||||
$esPage->getTranslation('fr')->ID,
|
||||
$esPage->getTranslation('fr_FR')->ID,
|
||||
$frPage->ID
|
||||
);
|
||||
$this->assertNotNull($esPage->getTranslation('en'));
|
||||
$this->assertNotNull($esPage->getTranslation('en_US'));
|
||||
$this->assertEquals(
|
||||
$esPage->getTranslation('en')->ID,
|
||||
$esPage->getTranslation('en_US')->ID,
|
||||
$enPage->ID
|
||||
);
|
||||
}
|
||||
|
||||
function testGetTranslationOnSiteTree() {
|
||||
$origPage = $this->objFromFixture('Page', 'testpage_en');
|
||||
$translatedPage = $origPage->createTranslation('fr');
|
||||
$getTranslationPage = $origPage->getTranslation('fr');
|
||||
$translatedPage = $origPage->createTranslation('fr_FR');
|
||||
$getTranslationPage = $origPage->getTranslation('fr_FR');
|
||||
|
||||
$this->assertNotNull($getTranslationPage);
|
||||
$this->assertEquals($getTranslationPage->ID, $translatedPage->ID);
|
||||
@ -116,18 +116,18 @@ class TranslatableTest extends FunctionalTest {
|
||||
$origPage = $this->objFromFixture('Page', 'testpage_en');
|
||||
|
||||
// through createTranslation()
|
||||
$translationAf = $origPage->createTranslation('af');
|
||||
$translationAf = $origPage->createTranslation('af_ZA');
|
||||
|
||||
// create a new language on an unrelated page which shouldnt be returned from $origPage
|
||||
$otherPage = new Page();
|
||||
$otherPage->write();
|
||||
$otherTranslationEs = $otherPage->createTranslation('es');
|
||||
$otherTranslationEs = $otherPage->createTranslation('es_ES');
|
||||
|
||||
$this->assertEquals(
|
||||
$origPage->getTranslatedLangs(),
|
||||
array(
|
||||
'af',
|
||||
//'en', // default language is not included
|
||||
'af_ZA',
|
||||
//'en_US', // default language is not included
|
||||
),
|
||||
'Language codes are returned specifically for the queried page through getTranslatedLangs()'
|
||||
);
|
||||
@ -143,7 +143,7 @@ class TranslatableTest extends FunctionalTest {
|
||||
|
||||
// manual creation of page without an original link
|
||||
$translationDeWithoutOriginal = new Page();
|
||||
$translationDeWithoutOriginal->Lang = 'de';
|
||||
$translationDeWithoutOriginal->Locale = 'de_DE';
|
||||
$translationDeWithoutOriginal->write();
|
||||
$this->assertEquals(
|
||||
$translationDeWithoutOriginal->getTranslatedLangs(),
|
||||
@ -154,7 +154,7 @@ class TranslatableTest extends FunctionalTest {
|
||||
|
||||
function testTranslationCanHaveSameURLSegment() {
|
||||
$origPage = $this->objFromFixture('Page', 'testpage_en');
|
||||
$translatedPage = $origPage->createTranslation('de');
|
||||
$translatedPage = $origPage->createTranslation('de_DE');
|
||||
$translatedPage->URLSegment = 'testpage';
|
||||
|
||||
$this->assertEquals($origPage->URLSegment, $translatedPage->URLSegment);
|
||||
@ -176,7 +176,7 @@ class TranslatableTest extends FunctionalTest {
|
||||
);
|
||||
|
||||
// then in "translation mode"
|
||||
$pageTranslated = $pageOrigLang->createTranslation('fr');
|
||||
$pageTranslated = $pageOrigLang->createTranslation('fr_FR');
|
||||
$fields = $pageTranslated->getCMSFields();
|
||||
$this->assertType(
|
||||
'TextField',
|
||||
@ -195,7 +195,7 @@ class TranslatableTest extends FunctionalTest {
|
||||
function testDataObjectGetWithReadingLanguage() {
|
||||
$origTestPage = $this->objFromFixture('Page', 'testpage_en');
|
||||
$otherTestPage = $this->objFromFixture('Page', 'othertestpage_en');
|
||||
$translatedPage = $origTestPage->createTranslation('de');
|
||||
$translatedPage = $origTestPage->createTranslation('de_DE');
|
||||
|
||||
// test in default language
|
||||
$resultPagesDefaultLang = DataObject::get(
|
||||
@ -208,7 +208,7 @@ class TranslatableTest extends FunctionalTest {
|
||||
$this->assertNotContains($translatedPage->ID, $resultPagesDefaultLang->column('ID'));
|
||||
|
||||
// test in custom language
|
||||
Translatable::set_reading_lang('de');
|
||||
Translatable::set_reading_locale('de_DE');
|
||||
$resultPagesCustomLang = DataObject::get(
|
||||
'Page',
|
||||
sprintf("\"SiteTree\".\"MenuTitle\" = '%s'", 'A Testpage')
|
||||
@ -219,12 +219,12 @@ class TranslatableTest extends FunctionalTest {
|
||||
// casting as a workaround for types not properly set on duplicated dataobjects from createTranslation()
|
||||
$this->assertContains((string)$translatedPage->ID, $resultPagesCustomLang->column('ID'));
|
||||
|
||||
Translatable::set_reading_lang('en');
|
||||
Translatable::set_reading_locale('en_US');
|
||||
}
|
||||
|
||||
function testDataObjectGetByIdWithReadingLanguage() {
|
||||
$origPage = $this->objFromFixture('Page', 'testpage_en');
|
||||
$translatedPage = $origPage->createTranslation('de');
|
||||
$translatedPage = $origPage->createTranslation('de_DE');
|
||||
$compareOrigPage = DataObject::get_by_id('Page', $origPage->ID);
|
||||
|
||||
$this->assertEquals(
|
||||
@ -236,10 +236,10 @@ class TranslatableTest extends FunctionalTest {
|
||||
|
||||
function testDataObjectGetOneWithReadingLanguage() {
|
||||
$origPage = $this->objFromFixture('Page', 'testpage_en');
|
||||
$translatedPage = $origPage->createTranslation('de');
|
||||
$translatedPage = $origPage->createTranslation('de_DE');
|
||||
|
||||
// running the same query twice with different
|
||||
Translatable::set_reading_lang('de');
|
||||
Translatable::set_reading_locale('de_DE');
|
||||
$compareTranslatedPage = DataObject::get_one(
|
||||
'Page',
|
||||
sprintf("\"SiteTree\".\"Title\" = '%s'", $translatedPage->Title)
|
||||
@ -252,17 +252,17 @@ class TranslatableTest extends FunctionalTest {
|
||||
);
|
||||
|
||||
// reset language to default
|
||||
Translatable::set_reading_lang('de');
|
||||
Translatable::set_reading_locale('de_DE');
|
||||
}
|
||||
|
||||
function testModifyTranslationWithDefaultReadingLang() {
|
||||
$origPage = $this->objFromFixture('Page', 'testpage_en');
|
||||
$translatedPage = $origPage->createTranslation('de');
|
||||
$translatedPage = $origPage->createTranslation('de_DE');
|
||||
|
||||
Translatable::set_reading_lang('en');
|
||||
Translatable::set_reading_locale('en_US');
|
||||
$translatedPage->Title = 'De Modified';
|
||||
$translatedPage->write();
|
||||
$savedTranslatedPage = $origPage->getTranslation('de');
|
||||
$savedTranslatedPage = $origPage->getTranslation('de_DE');
|
||||
$this->assertEquals(
|
||||
$savedTranslatedPage->Title,
|
||||
'De Modified',
|
||||
@ -277,9 +277,9 @@ class TranslatableTest extends FunctionalTest {
|
||||
|
||||
function testSiteTreePublication() {
|
||||
$origPage = $this->objFromFixture('Page', 'testpage_en');
|
||||
$translatedPage = $origPage->createTranslation('de');
|
||||
$translatedPage = $origPage->createTranslation('de_DE');
|
||||
|
||||
Translatable::set_reading_lang('en');
|
||||
Translatable::set_reading_locale('en_US');
|
||||
$origPage->Title = 'En Modified';
|
||||
$origPage->write();
|
||||
// modifying a record in language which is not the reading language should still write the record correctly
|
||||
@ -296,14 +296,14 @@ class TranslatableTest extends FunctionalTest {
|
||||
|
||||
function testDeletingTranslationKeepsOriginal() {
|
||||
$origPage = $this->objFromFixture('Page', 'testpage_en');
|
||||
$translatedPage = $origPage->createTranslation('de');
|
||||
$translatedPage = $origPage->createTranslation('de_DE');
|
||||
$translatedPageID = $translatedPage->ID;
|
||||
$translatedPage->delete();
|
||||
|
||||
$translatedPage->flushCache();
|
||||
$origPage->flushCache();
|
||||
|
||||
$this->assertNull($origPage->getTranslation('de'));
|
||||
$this->assertNull($origPage->getTranslation('de_DE'));
|
||||
$this->assertNotNull(DataObject::get_by_id('Page', $origPage->ID));
|
||||
}
|
||||
|
||||
@ -314,13 +314,13 @@ class TranslatableTest extends FunctionalTest {
|
||||
$child3Page = $this->objFromFixture('Page', 'child3');
|
||||
$grandchildPage = $this->objFromFixture('Page', 'grandchild');
|
||||
|
||||
$parentPageTranslated = $parentPage->createTranslation('de');
|
||||
$parentPageTranslated = $parentPage->createTranslation('de_DE');
|
||||
$child4PageTranslated = new SiteTree();
|
||||
$child4PageTranslated->Lang = 'de';
|
||||
$child4PageTranslated->Locale = 'de_DE';
|
||||
$child4PageTranslated->ParentID = $parentPageTranslated->ID;
|
||||
$child4PageTranslated->write();
|
||||
|
||||
Translatable::set_reading_lang('en');
|
||||
Translatable::set_reading_locale('en_US');
|
||||
$this->assertEquals(
|
||||
$parentPage->Children()->column('ID'),
|
||||
array(
|
||||
@ -331,7 +331,7 @@ class TranslatableTest extends FunctionalTest {
|
||||
"Showing Children() in default language doesnt show children in other languages"
|
||||
);
|
||||
|
||||
Translatable::set_reading_lang('de');
|
||||
Translatable::set_reading_locale('de_DE');
|
||||
$parentPage->flushCache();
|
||||
$this->assertEquals(
|
||||
$parentPageTranslated->Children()->column('ID'),
|
||||
@ -340,7 +340,7 @@ class TranslatableTest extends FunctionalTest {
|
||||
);
|
||||
|
||||
// reset language
|
||||
Translatable::set_reading_lang('en');
|
||||
Translatable::set_reading_locale('en_US');
|
||||
}
|
||||
|
||||
function testHierarchyLiveStageChildren() {
|
||||
@ -351,20 +351,20 @@ class TranslatableTest extends FunctionalTest {
|
||||
$child3Page = $this->objFromFixture('Page', 'child3');
|
||||
$grandchildPage = $this->objFromFixture('Page', 'grandchild');
|
||||
|
||||
$parentPageTranslated = $parentPage->createTranslation('de');
|
||||
$parentPageTranslated = $parentPage->createTranslation('de_DE');
|
||||
|
||||
$child4PageTranslated = new SiteTree();
|
||||
$child4PageTranslated->Lang = 'de';
|
||||
$child4PageTranslated->Locale = 'de_DE';
|
||||
$child4PageTranslated->ParentID = $parentPageTranslated->ID;
|
||||
$child4PageTranslated->write();
|
||||
$child4PageTranslated->publish('Stage', 'Live');
|
||||
|
||||
$child5PageTranslated = new SiteTree();
|
||||
$child5PageTranslated->Lang = 'de';
|
||||
$child5PageTranslated->Locale = 'de_DE';
|
||||
$child5PageTranslated->ParentID = $parentPageTranslated->ID;
|
||||
$child5PageTranslated->write();
|
||||
|
||||
Translatable::set_reading_lang('en');
|
||||
Translatable::set_reading_lang('en_US');
|
||||
$this->assertNotNull($parentPage->liveChildren());
|
||||
$this->assertEquals(
|
||||
$parentPage->liveChildren()->column('ID'),
|
||||
@ -384,7 +384,7 @@ class TranslatableTest extends FunctionalTest {
|
||||
"Showing stageChildren() in default language doesnt show children in other languages"
|
||||
);
|
||||
|
||||
Translatable::set_reading_lang('de');
|
||||
Translatable::set_reading_lang('de_DE');
|
||||
$parentPage->flushCache();
|
||||
$this->assertNotNull($parentPageTranslated->liveChildren());
|
||||
$this->assertEquals(
|
||||
@ -403,35 +403,35 @@ class TranslatableTest extends FunctionalTest {
|
||||
);
|
||||
|
||||
// reset language
|
||||
Translatable::set_reading_lang('en');
|
||||
Translatable::set_reading_lang('en_US');
|
||||
}
|
||||
|
||||
function testTranslatablePropertiesOnSiteTree() {
|
||||
$origObj = $this->objFromFixture('TranslatableTest_Page', 'testpage_en');
|
||||
$translatedObj = $origObj->createTranslation('fr');
|
||||
$translatedObj->TranslatableProperty = 'Fr';
|
||||
$translatedObj = $origObj->createTranslation('fr_FR');
|
||||
$translatedObj->TranslatableProperty = 'fr_FR';
|
||||
$translatedObj->write();
|
||||
|
||||
$this->assertEquals(
|
||||
$origObj->TranslatableProperty,
|
||||
'En',
|
||||
'en_US',
|
||||
'Creating a translation doesnt affect database field on original object'
|
||||
);
|
||||
$this->assertEquals(
|
||||
$translatedObj->TranslatableProperty,
|
||||
'Fr',
|
||||
'fr_FR',
|
||||
'Translated object saves database field independently of original object'
|
||||
);
|
||||
}
|
||||
|
||||
function testCreateTranslationOnSiteTree() {
|
||||
$origPage = $this->objFromFixture('Page', 'testpage_en');
|
||||
$translatedPage = $origPage->createTranslation('de');
|
||||
$translatedPage = $origPage->createTranslation('de_DE');
|
||||
|
||||
$this->assertEquals($translatedPage->Lang, 'de');
|
||||
$this->assertEquals($translatedPage->Locale, 'de_DE');
|
||||
$this->assertNotEquals($translatedPage->ID, $origPage->ID);
|
||||
|
||||
$subsequentTranslatedPage = $origPage->createTranslation('de');
|
||||
$subsequentTranslatedPage = $origPage->createTranslation('de_DE');
|
||||
$this->assertEquals(
|
||||
$translatedPage->ID,
|
||||
$subsequentTranslatedPage->ID,
|
||||
@ -441,43 +441,43 @@ class TranslatableTest extends FunctionalTest {
|
||||
|
||||
function testTranslatablePropertiesOnDataObject() {
|
||||
$origObj = $this->objFromFixture('TranslatableTest_DataObject', 'testobject_en');
|
||||
$translatedObj = $origObj->createTranslation('fr');
|
||||
$translatedObj->TranslatableProperty = 'Fr';
|
||||
$translatedObj->TranslatableDecoratedProperty = 'Fr';
|
||||
$translatedObj = $origObj->createTranslation('fr_FR');
|
||||
$translatedObj->TranslatableProperty = 'fr_FR';
|
||||
$translatedObj->TranslatableDecoratedProperty = 'fr_FR';
|
||||
$translatedObj->write();
|
||||
|
||||
$this->assertEquals(
|
||||
$origObj->TranslatableProperty,
|
||||
'En',
|
||||
'en_US',
|
||||
'Creating a translation doesnt affect database field on original object'
|
||||
);
|
||||
$this->assertEquals(
|
||||
$origObj->TranslatableDecoratedProperty,
|
||||
'En',
|
||||
'en_US',
|
||||
'Creating a translation doesnt affect decorated database field on original object'
|
||||
);
|
||||
$this->assertEquals(
|
||||
$translatedObj->TranslatableProperty,
|
||||
'Fr',
|
||||
'fr_FR',
|
||||
'Translated object saves database field independently of original object'
|
||||
);
|
||||
$this->assertEquals(
|
||||
$translatedObj->TranslatableDecoratedProperty,
|
||||
'Fr',
|
||||
'fr_FR',
|
||||
'Translated object saves decorated database field independently of original object'
|
||||
);
|
||||
}
|
||||
|
||||
function testCreateTranslationWithoutOriginal() {
|
||||
$origParentPage = $this->objFromFixture('Page', 'testpage_en');
|
||||
$translatedParentPage = $origParentPage->createTranslation('de');
|
||||
$translatedParentPage = $origParentPage->createTranslation('de_DE');
|
||||
|
||||
$translatedPageWithoutOriginal = new SiteTree();
|
||||
$translatedPageWithoutOriginal->ParentID = $translatedParentPage->ID;
|
||||
$translatedPageWithoutOriginal->Lang = 'de';
|
||||
$translatedPageWithoutOriginal->Locale = 'de_DE';
|
||||
$translatedPageWithoutOriginal->write();
|
||||
|
||||
Translatable::set_reading_lang('de');
|
||||
Translatable::set_reading_locale('de_DE');
|
||||
$this->assertEquals(
|
||||
$translatedParentPage->stageChildren()->column('ID'),
|
||||
array(
|
||||
@ -486,7 +486,7 @@ class TranslatableTest extends FunctionalTest {
|
||||
"Children() still works on a translated page even if no translation group is set"
|
||||
);
|
||||
|
||||
Translatable::set_reading_lang('en');
|
||||
Translatable::set_reading_locale('en_US');
|
||||
}
|
||||
|
||||
function testCreateTranslationTranslatesUntranslatedParents() {
|
||||
@ -495,23 +495,23 @@ class TranslatableTest extends FunctionalTest {
|
||||
$child1PageOrigID = $child1Page->ID;
|
||||
$grandchildPage = $this->objFromFixture('Page', 'grandchild');
|
||||
|
||||
$this->assertFalse($grandchildPage->hasTranslation('de'));
|
||||
$this->assertFalse($child1Page->hasTranslation('de'));
|
||||
$this->assertFalse($parentPage->hasTranslation('de'));
|
||||
$this->assertFalse($grandchildPage->hasTranslation('de_DE'));
|
||||
$this->assertFalse($child1Page->hasTranslation('de_DE'));
|
||||
$this->assertFalse($parentPage->hasTranslation('de_DE'));
|
||||
|
||||
$translatedGrandChildPage = $grandchildPage->createTranslation('de');
|
||||
$this->assertTrue($grandchildPage->hasTranslation('de'));
|
||||
$this->assertTrue($child1Page->hasTranslation('de'));
|
||||
$this->assertTrue($parentPage->hasTranslation('de'));
|
||||
$translatedGrandChildPage = $grandchildPage->createTranslation('de_DE');
|
||||
$this->assertTrue($grandchildPage->hasTranslation('de_DE'));
|
||||
$this->assertTrue($child1Page->hasTranslation('de_DE'));
|
||||
$this->assertTrue($parentPage->hasTranslation('de_DE'));
|
||||
}
|
||||
|
||||
function testHierarchyAllChildrenIncludingDeleted() {
|
||||
// Original tree in 'en':
|
||||
// Original tree in 'en_US':
|
||||
// parent
|
||||
// child1 (Live only, deleted from stage)
|
||||
// child2 (Stage only, never published)
|
||||
// child3 (Stage only, never published, untranslated)
|
||||
// Translated tree in 'de':
|
||||
// Translated tree in 'de_DE':
|
||||
// parent
|
||||
// child1 (Live only, deleted from stage)
|
||||
// child2 (Stage only)
|
||||
@ -521,7 +521,7 @@ class TranslatableTest extends FunctionalTest {
|
||||
$parentPageID = $parentPage->ID;
|
||||
|
||||
// Create parent translation
|
||||
$translatedParentPage = $parentPage->createTranslation('de');
|
||||
$translatedParentPage = $parentPage->createTranslation('de_DE');
|
||||
$translatedParentPageID = $translatedParentPage->ID;
|
||||
|
||||
// Create child1
|
||||
@ -530,7 +530,7 @@ class TranslatableTest extends FunctionalTest {
|
||||
$child1Page->publish('Stage', 'Live');
|
||||
|
||||
// Create child1 translation
|
||||
$child1PageTranslated = $child1Page->createTranslation('de');
|
||||
$child1PageTranslated = $child1Page->createTranslation('de_DE');
|
||||
$child1PageTranslatedID = $child1PageTranslated->ID;
|
||||
$child1PageTranslated->publish('Stage', 'Live');
|
||||
$child1PageTranslated->deleteFromStage('Stage'); // deleted from stage only, record still exists on live
|
||||
@ -541,7 +541,7 @@ class TranslatableTest extends FunctionalTest {
|
||||
$child2PageID = $child2Page->ID;
|
||||
|
||||
// Create child2 translation
|
||||
$child2PageTranslated = $child2Page->createTranslation('de');
|
||||
$child2PageTranslated = $child2Page->createTranslation('de_DE');
|
||||
$child2PageTranslatedID = $child2PageTranslated->ID;
|
||||
|
||||
// Create child3
|
||||
@ -549,7 +549,7 @@ class TranslatableTest extends FunctionalTest {
|
||||
$child3PageID = $child3Page->ID;
|
||||
|
||||
// on original parent in default language
|
||||
Translatable::set_reading_lang('en');
|
||||
Translatable::set_reading_locale('en_US');
|
||||
SiteTree::flush_and_destroy_cache();
|
||||
$parentPage = $this->objFromFixture('Page', 'parent');
|
||||
$children = $parentPage->AllChildrenIncludingDeleted();
|
||||
@ -564,7 +564,7 @@ class TranslatableTest extends FunctionalTest {
|
||||
);
|
||||
|
||||
// on original parent in translation mode
|
||||
Translatable::set_reading_lang('de');
|
||||
Translatable::set_reading_locale('de_DE');
|
||||
SiteTree::flush_and_destroy_cache();
|
||||
$parentPage = $this->objFromFixture('Page', 'parent');
|
||||
$this->assertEquals(
|
||||
@ -576,11 +576,11 @@ class TranslatableTest extends FunctionalTest {
|
||||
"Showing AllChildrenIncludingDeleted() in translation mode with parent page in default language shows children in default language"
|
||||
);
|
||||
|
||||
// @todo getTranslation() doesn't switch languages for future calls, its handled statically through set_reading_lang()
|
||||
// @todo getTranslation() doesn't switch languages for future calls, its handled statically through set_reading_locale()
|
||||
// // on translated page in translation mode using getTranslation()
|
||||
// SiteTree::flush_and_destroy_cache();
|
||||
// $parentPage = $this->objFromFixture('Page', 'parent');
|
||||
// $translatedParentPage = $parentPage->getTranslation('de');
|
||||
// $translatedParentPage = $parentPage->getTranslation('de_DE');
|
||||
// $this->assertEquals(
|
||||
// $translatedParentPage->AllChildrenIncludingDeleted()->column('ID'),
|
||||
// array(
|
||||
@ -591,7 +591,7 @@ class TranslatableTest extends FunctionalTest {
|
||||
// );
|
||||
|
||||
// reset language
|
||||
Translatable::set_reading_lang('en');
|
||||
Translatable::set_reading_locale('en_US');
|
||||
}
|
||||
|
||||
function testRootUrlDefaultsToTranslatedUrlSegment() {
|
||||
@ -599,14 +599,14 @@ class TranslatableTest extends FunctionalTest {
|
||||
|
||||
$origPage = $this->objFromFixture('Page', 'homepage_en');
|
||||
$origPage->publish('Stage', 'Live');
|
||||
$translationDe = $origPage->createTranslation('de');
|
||||
$translationDe = $origPage->createTranslation('de_DE');
|
||||
$translationDe->URLSegment = 'heim';
|
||||
$translationDe->write();
|
||||
$translationDe->publish('Stage', 'Live');
|
||||
|
||||
// test with translatable enabled
|
||||
$_SERVER['HTTP_HOST'] = '/?lang=de';
|
||||
Translatable::set_reading_lang('de');
|
||||
$_SERVER['HTTP_HOST'] = '/?locale=de';
|
||||
Translatable::set_reading_locale('de_DE');
|
||||
$this->assertEquals(
|
||||
RootURLController::get_homepage_urlsegment(),
|
||||
'heim',
|
||||
@ -624,7 +624,7 @@ class TranslatableTest extends FunctionalTest {
|
||||
Translatable::enable();
|
||||
|
||||
// setting back to default
|
||||
Translatable::set_reading_lang('en');
|
||||
Translatable::set_reading_locale('en_US');
|
||||
$_SERVER['HTTP_HOST'] = $_originalHost;
|
||||
}
|
||||
}
|
||||
|
@ -2,17 +2,17 @@ Page:
|
||||
homepage_en:
|
||||
Title: Home
|
||||
URLSegment: home
|
||||
Lang: en
|
||||
Locale: en_US
|
||||
testpage_en:
|
||||
Title: Home
|
||||
MenuTitle: A Testpage
|
||||
URLSegment: testpage
|
||||
Lang: en
|
||||
Locale: en_US
|
||||
othertestpage_en:
|
||||
Title: Other Testpage
|
||||
MenuTitle: A Testpage
|
||||
URLSegment: othertestpage
|
||||
Lang: en
|
||||
Locale: en_US
|
||||
parent:
|
||||
Title: Parent
|
||||
URLSegment: parent
|
||||
@ -34,10 +34,10 @@ Page:
|
||||
Parent: =>Page.child1
|
||||
TranslatableTest_DataObject:
|
||||
testobject_en:
|
||||
TranslatableProperty: En
|
||||
TranslatableDecoratedProperty: En
|
||||
TranslatableProperty: en_US
|
||||
TranslatableDecoratedProperty: en_US
|
||||
TranslatableTest_Page:
|
||||
testpage_en:
|
||||
Title: En
|
||||
TranslatableProperty: En
|
||||
TranslatableProperty: en_US
|
||||
URLSegment: testpage-en
|
@ -12,10 +12,10 @@ class TranslatableSearchFormTest extends FunctionalTest {
|
||||
protected $recreateTempDb = true;
|
||||
|
||||
function setUp() {
|
||||
$this->origTranslatableSettings['enabled'] = Translatable::is_enabled();
|
||||
$this->origTranslatableSettings['default_lang'] = Translatable::default_lang();
|
||||
$this->origTranslatableSettings['enabled'] = Translatable::is_enabled();default_locale
|
||||
$this->origTranslatableSettings['default_locale'] = Translatable::default_locale();
|
||||
Translatable::enable();
|
||||
Translatable::set_default_lang("en");
|
||||
Translatable::set_default_locale("en");
|
||||
|
||||
// needs to recreate the database schema with language properties
|
||||
self::kill_temp_db();
|
||||
@ -34,7 +34,7 @@ class TranslatableSearchFormTest extends FunctionalTest {
|
||||
function tearDown() {
|
||||
if(!$this->origTranslatableSettings['enabled']) Translatable::disable();
|
||||
|
||||
Translatable::set_default_lang($this->origTranslatableSettings['default_lang']);
|
||||
Translatable::set_default_locale($this->origTranslatableSettings['default_locale']);
|
||||
|
||||
self::kill_temp_db();
|
||||
self::create_temp_db();
|
||||
@ -53,7 +53,7 @@ class TranslatableSearchFormTest extends FunctionalTest {
|
||||
$translatedPublishedPage->write();
|
||||
$translatedPublishedPage->publish('Stage', 'Live');
|
||||
|
||||
// Translatable::set_reading_lang() can't be used because the context
|
||||
// Translatable::set_reading_locale() can't be used because the context
|
||||
// from the holder is not present here - we set the language explicitly
|
||||
// through a pseudo GET variable in getResults()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user