Merge branch '2.3' into 2.4

This commit is contained in:
Robbie Averill 2019-07-23 15:38:42 +02:00
parent dfa1c965a5
commit f761674834
28 changed files with 245 additions and 148 deletions

View File

@ -1,29 +1,26 @@
# See https://github.com/silverstripe-labs/silverstripe-travis-support for setup details
# See https://github.com/silverstripe/silverstripe-travis-support for setup details
language: php
php:
- 5.3
env:
- DB=MYSQL CORE_RELEASE=3
dist: trusty
matrix:
include:
- php: 5.4
env: DB=PGSQL CORE_RELEASE=3
- php: 5.5
env: DB=MYSQL CORE_RELEASE=3.2
- php: 5.6
env: DB=MYSQL CORE_RELEASE=3.2
- php: '7.1'
env: DB=PGSQL CORE_RELEASE=3.7
- php: '7.1'
env: DB=MYSQL CORE_RELEASE=3.7
- php: '7.2'
env: DB=MYSQL CORE_RELEASE=3.7
- php: '7.3'
env: DB=MYSQL CORE_RELEASE=3.7
before_script:
- pear -q install --onlyreqdeps pear/PHP_CodeSniffer
- phpenv rehash
- git clone git://github.com/silverstripe-labs/silverstripe-travis-support.git ~/travis-support
- git clone git://github.com/silverstripe/silverstripe-travis-support.git ~/travis-support
- php ~/travis-support/travis_setup.php --source `pwd` --target ~/builds/ss
- cd ~/builds/ss
script:
- vendor/bin/phpunit translatable/tests/
- phpcs --encoding=utf-8 --tab-width=4 --standard=translatable/tests/phpcs -np translatable
- vendor/bin/phpunit translatable/tests
- vendor/bin/phpcs --encoding=utf-8 --tab-width=4 --standard=translatable/tests/phpcs -np translatable

View File

@ -1,6 +1,7 @@
# Translatable module for SilverStripe CMS #
[![Build Status](https://secure.travis-ci.org/silverstripe/silverstripe-translatable.png?branch=2.1)](http://travis-ci.org/silverstripe/silverstripe-translatable)
[![SilverStripe supported module](https://img.shields.io/badge/silverstripe-supported-0071C4.svg)](https://www.silverstripe.org/software/addons/silverstripe-commercially-supported-module-list/)
## Introduction ##
@ -27,7 +28,7 @@ third party translation interface, transifex.com.
Newly added strings will be periodically uploaded there for translation,
and any new translations will be merged back to the project source code.
Please use [https://www.transifex.com/projects/p/silverstripe-translatable/](https://www.transifex.com/projects/p/silverstripe-translatable/) to contribute translations,
Please use [https://www.transifex.com/silverstripe/silverstripe-translatable/](https://www.transifex.com/projects/p/silverstripe-translatable/) to contribute translations,
rather than sending pull requests with YAML files.
See the ["i18n" topic](http://doc.silverstripe.org/framework/en/trunk/topics/i18n) on doc.silverstripe.org for more details.
See the ["i18n" topic](https://docs.silverstripe.org/en/3/developer_guides/i18n/) on doc.silverstripe.org for more details.

View File

@ -21,7 +21,7 @@ class LanguageDropdownField extends GroupedDropdownField {
* @param string $list Indicates the source language list.
* Can be either Common-English, Common-Native, Locale-English, Locale-Native
*/
function __construct($name, $title, $excludeLocales = array(),
public function __construct($name, $title = null, $excludeLocales = array(),
$translatingClass = 'SiteTree', $list = 'Common-English', $instance = null
) {
$usedLocalesWithTitle = Translatable::get_existing_content_languages($translatingClass);

View File

@ -743,7 +743,12 @@ class Translatable extends DataExtension implements PermissionProvider {
if(!$obj || $obj->ObsoleteClassName) continue;
$obj->Locale = Translatable::default_locale();
$obj->writeToStage($stage);
$oldMode = Versioned::get_reading_mode();
Versioned::reading_stage($stage);
$obj->writeWithoutVersion();
Versioned::set_reading_mode($oldMode);
$obj->addTranslationGroup($obj->ID);
$obj->destroy();
unset($obj);
@ -928,13 +933,7 @@ class Translatable extends DataExtension implements PermissionProvider {
// This is to prevent the overhead of writing all translations when
// the class didn't actually change.
$baseDataClass = ClassInfo::baseDataClass($this->owner->class);
$currentStage = Versioned::current_stage();
$fresh = Versioned::get_one_by_stage(
$baseDataClass,
Versioned::current_stage(),
'"ID" = ' . $this->owner->ID,
null
);
$fresh = DataObject::get($baseDataClass)->byId($this->owner->ID);
if ($fresh) {
$changed = $changedFields['ClassName']['after'] != $fresh->ClassName;
}
@ -1065,69 +1064,71 @@ class Translatable extends DataExtension implements PermissionProvider {
$alreadyTranslatedLocales[$this->owner->Locale] = $this->owner->Locale;
$alreadyTranslatedLocales = array_combine($alreadyTranslatedLocales, $alreadyTranslatedLocales);
// Check if fields exist already to avoid adding them twice on repeat invocations
$tab = $fields->findOrMakeTab('Root.Translations', _t('Translatable.TRANSLATIONS', 'Translations'));
if(!$tab->fieldByName('CreateTransHeader')) {
$tab->push(new HeaderField(
'CreateTransHeader',
_t('Translatable.CREATE', 'Create new translation'),
2
));
}
if(!$tab->fieldByName('NewTransLang') && !$tab->fieldByName('AllTransCreated')) {
$langDropdown = LanguageDropdownField::create(
"NewTransLang",
_t('Translatable.NEWLANGUAGE', 'New language'),
$alreadyTranslatedLocales,
'SiteTree',
'Locale-English',
$this->owner
)->addExtraClass('languageDropdown no-change-track');
$tab->push($langDropdown);
$canAddLocale = (count($langDropdown->getSource()) > 0);
if($canAddLocale) {
// Only add create button if new languages are available
$tab->push(
$createButton = InlineFormAction::create(
'createtranslation',
_t('Translatable.CREATEBUTTON', 'Create')
)->addExtraClass('createTranslationButton')
);
$createButton->includeDefaultJS(false); // not fluent API...
} else {
$tab->removeByName('NewTransLang');
$tab->push(new LiteralField(
'AllTransCreated',
_t('Translatable.ALLCREATED', 'All allowed translations have been created.')
if ($fields->hasTabSet()) {
// Check if fields exist already to avoid adding them twice on repeat invocations
$tab = $fields->findOrMakeTab('Root.Translations', _t('Translatable.TRANSLATIONS', 'Translations'));
if(!$tab->fieldByName('CreateTransHeader')) {
$tab->push(new HeaderField(
'CreateTransHeader',
_t('Translatable.CREATE', 'Create new translation'),
2
));
}
}
if($alreadyTranslatedLocales) {
if(!$tab->fieldByName('ExistingTransHeader')) {
$tab->push(new HeaderField(
'ExistingTransHeader',
_t('Translatable.EXISTING', 'Existing translations'),
3
));
if (!$tab->fieldByName('existingtrans')) {
$existingTransHTML = '<ul>';
if ($existingTranslations = $this->getTranslations()) {
foreach ($existingTranslations as $existingTranslation) {
if ($existingTranslation && $existingTranslation->hasMethod('CMSEditLink')) {
$existingTransHTML .= sprintf(
'<li><a href="%s">%s</a></li>',
Controller::join_links(
$existingTranslation->CMSEditLink(),
'?Locale=' . $existingTranslation->Locale
),
i18n::get_locale_name($existingTranslation->Locale)
);
if(!$tab->fieldByName('NewTransLang') && !$tab->fieldByName('AllTransCreated')) {
$langDropdown = LanguageDropdownField::create(
"NewTransLang",
_t('Translatable.NEWLANGUAGE', 'New language'),
$alreadyTranslatedLocales,
'SiteTree',
'Locale-English',
$this->owner
)->addExtraClass('languageDropdown no-change-track');
$tab->push($langDropdown);
$canAddLocale = (count($langDropdown->getSource()) > 0);
if($canAddLocale) {
// Only add create button if new languages are available
$tab->push(
$createButton = InlineFormAction::create(
'createtranslation',
_t('Translatable.CREATEBUTTON', 'Create')
)->addExtraClass('createTranslationButton')
);
$createButton->includeDefaultJS(false); // not fluent API...
} else {
$tab->removeByName('NewTransLang');
$tab->push(new LiteralField(
'AllTransCreated',
_t('Translatable.ALLCREATED', 'All allowed translations have been created.')
));
}
}
if($alreadyTranslatedLocales) {
if(!$tab->fieldByName('ExistingTransHeader')) {
$tab->push(new HeaderField(
'ExistingTransHeader',
_t('Translatable.EXISTING', 'Existing translations'),
3
));
if (!$tab->fieldByName('existingtrans')) {
$existingTransHTML = '<ul>';
if ($existingTranslations = $this->getTranslations()) {
foreach ($existingTranslations as $existingTranslation) {
if ($existingTranslation && $existingTranslation->hasMethod('CMSEditLink')) {
$existingTransHTML .= sprintf(
'<li><a href="%s">%s</a></li>',
Controller::join_links(
$existingTranslation->CMSEditLink(),
'?Locale=' . $existingTranslation->Locale
),
i18n::get_locale_name($existingTranslation->Locale)
);
}
}
}
$existingTransHTML .= '</ul>';
$tab->push(new LiteralField('existingtrans', $existingTransHTML));
}
$existingTransHTML .= '</ul>';
$tab->push(new LiteralField('existingtrans', $existingTransHTML));
}
}
}
@ -1293,20 +1294,16 @@ class Translatable extends DataExtension implements PermissionProvider {
// exclude the language of the current owner
$filter .= sprintf(' AND "%s"."Locale" != \'%s\'', $baseDataClass, $this->owner->Locale);
}
$currentStage = Versioned::current_stage();
$joinOnClause = sprintf('"%s_translationgroups"."OriginalID" = "%s"."ID"', $baseDataClass, $baseDataClass);
if($this->owner->hasExtension("Versioned")) {
if($stage) Versioned::reading_stage($stage);
if($this->owner->hasExtension("Versioned") && $stage) {
$translations = Versioned::get_by_stage(
$baseDataClass,
Versioned::current_stage(),
$stage,
$filter,
null
)->leftJoin("{$baseDataClass}_translationgroups", $joinOnClause);
if($stage) Versioned::reading_stage($currentStage);
} else {
$class = $this->owner->class;
$translations = $baseDataClass::get()
$translations = DataObject::get($baseDataClass)
->where($filter)
->leftJoin("{$baseDataClass}_translationgroups", $joinOnClause);
}
@ -1476,6 +1473,11 @@ class Translatable extends DataExtension implements PermissionProvider {
$urlSegment = $newTranslation->URLSegment;
}
if (URLSegmentFilter::singleton()->getAllowMultibyte()) {
// Decode the URL segment, it will be re-encoded again on write
$urlSegment = rawurldecode($urlSegment);
}
// Only make segment unique if it should be enforced
if(Config::inst()->get('Translatable', 'enforce_global_unique_urls')) {
$newTranslation->URLSegment = $urlSegment . '-' . i18n::convert_rfc1766($locale);
@ -1572,15 +1574,15 @@ class Translatable extends DataExtension implements PermissionProvider {
function MetaTags(&$tags) {
$template = '<link rel="alternate" type="text/html" title="%s" hreflang="%s" href="%s" />' . "\n";
$translations = $this->owner->getTranslations();
if($translations) {
if($translations->count()) {
$translations = $translations->toArray();
$translations[] = $this->owner;
foreach($translations as $translation) {
$tags .= sprintf($template,
Convert::raw2xml($translation->Title),
i18n::convert_rfc1766($translation->Locale),
$translation->AbsoluteLink()
foreach($translations as $translation) {
$tags .= sprintf($template,
Convert::raw2xml($translation->Title),
i18n::convert_rfc1766($translation->Locale),
$translation->AbsoluteLink()
);
}
}
@ -1766,7 +1768,7 @@ class Translatable extends DataExtension implements PermissionProvider {
* @deprecated 2.4 Use get_reading_locale()
*/
static function get_reading_lang() {
return i18n::get_lang_from_locale(self::get_reading_locale());
return i18n::get_lang_from_locale(self::get_current_locale());
}
/**

View File

@ -24,10 +24,8 @@
"silverstripe/cms": "~3.2"
},
"require-dev": {
"silverstripe/postgresql": "*",
"silverstripe/sqlite3": "*",
"silverstripe/mssql": "*",
"phpunit/PHPUnit": "~3.7@stable"
"phpunit/phpunit": "^5.7",
"squizlabs/php_codesniffer": "^3.0"
},
"extra": {
"screenshots": [

View File

@ -16,7 +16,7 @@ ar:
TRANSLATEALLPERMISSION: 'ترجم إلى جميع اللغات المتاحة'
TRANSLATEPERMISSION: 'ترجم %s'
TRANSLATEVIEWLANGS: 'أعرض قائمة اللغات'
TRANSLATIONS: تراجم
TRANSLATIONS: 'تراجم'
Translatable_Transform:
OriginalCheckboxLabel: 'الأصلية: {قيمة}'
OriginalFieldLabel: 'الأصلي {عنوان}'

View File

@ -18,7 +18,7 @@ bs:
TRANSLATEVIEWLANGS: 'Padajući meni jezika'
TRANSLATIONS: Prevodi
Translatable_Transform:
CheckboxValueNo: 'Ne'
CheckboxValueYes: 'Da'
CheckboxValueNo: Ne
CheckboxValueYes: Da
OriginalCheckboxLabel: 'Original: {value}'
OriginalFieldLabel: 'Original: {title}'

View File

@ -18,7 +18,7 @@ cs:
TRANSLATEVIEWLANGS: 'Zobrazit seznam jazyků'
TRANSLATIONS: Překlady
Translatable_Transform:
CheckboxValueNo: 'Ne'
CheckboxValueYes: 'Ano'
CheckboxValueNo: Ne
CheckboxValueYes: Ano
OriginalCheckboxLabel: 'Původní: {value}'
OriginalFieldLabel: 'Původní {title}'

View File

@ -18,7 +18,7 @@ cs_CZ:
TRANSLATEVIEWLANGS: 'Zobrazit jazykový rozbalovací seznam'
TRANSLATIONS: Překlady
Translatable_Transform:
CheckboxValueNo: 'Ne'
CheckboxValueYes: 'Ano'
CheckboxValueNo: Ne
CheckboxValueYes: Ano
OriginalCheckboxLabel: 'Původní: {value}'
OriginalFieldLabel: 'Původní {title}'

View File

@ -18,7 +18,7 @@ de:
TRANSLATEVIEWLANGS: 'Kann die verfügbaren Sprachen sehen'
TRANSLATIONS: Übersetzungen
Translatable_Transform:
CheckboxValueNo: 'Nein'
CheckboxValueYes: 'Ja'
CheckboxValueNo: Nein
CheckboxValueYes: Ja
OriginalCheckboxLabel: 'Original: {value}'
OriginalFieldLabel: 'Original {title}'

View File

@ -18,7 +18,7 @@ eo:
TRANSLATEVIEWLANGS: 'Vidigi lingvan falliston'
TRANSLATIONS: Tradukoj
Translatable_Transform:
CheckboxValueNo: 'Ne'
CheckboxValueYes: 'Jes'
CheckboxValueNo: Ne
CheckboxValueYes: Jes
OriginalCheckboxLabel: 'Origina: {value}'
OriginalFieldLabel: 'Origina: {title}'

View File

@ -16,5 +16,5 @@ et_EE:
TRANSLATEPERMISSION: 'Tõlgi: %s'
TRANSLATIONS: Tõlked
Translatable_Transform:
CheckboxValueNo: 'Ei'
CheckboxValueYes: 'Jah'
CheckboxValueNo: Ei
CheckboxValueYes: Jah

View File

@ -16,9 +16,9 @@ fa_IR:
TRANSLATEALLPERMISSION: 'ترجمه به تمام زبان های موجود'
TRANSLATEPERMISSION: 'ترجمه %s'
TRANSLATEVIEWLANGS: 'نمایش منوی زبان'
TRANSLATIONS: ترجمه
TRANSLATIONS: 'ترجمه'
Translatable_Transform:
CheckboxValueNo: 'خیر'
CheckboxValueYes: 'بله'
CheckboxValueNo: خیر
CheckboxValueYes: بله
OriginalCheckboxLabel: 'اصل: {value}'
OriginalFieldLabel: 'اصل {title}'

View File

@ -18,7 +18,7 @@ fi_FI:
TRANSLATEVIEWLANGS: 'Näytä kielet'
TRANSLATIONS: Käännökset
Translatable_Transform:
CheckboxValueNo: 'Ei'
CheckboxValueYes: 'Kyllä'
CheckboxValueNo: Ei
CheckboxValueYes: Kyllä
OriginalCheckboxLabel: 'Alkuperäinen: {value}'
OriginalFieldLabel: 'Alkuperäinen {title}'

24
lang/hr.yml Normal file
View File

@ -0,0 +1,24 @@
hr:
CMSMain:
LANGUAGEDROPDOWNLABEL: Jezik
CMSMain_left:
GO: Kreni
Form:
LANGAOTHER: 'Ostali jezici'
LANGAVAIL: 'Dostupni jezici'
Translatable:
ALLCREATED: 'Svi dozvoljeni prijevodi su kreirani.'
CREATE: 'Kreiraj novi prijevod'
CREATEBUTTON: Kreiraj
EXISTING: 'Postojeći prijevodi'
NEWLANGUAGE: 'Novi jezik'
NOTICENEWPAGE: 'Molimo spremite ovu stranicu prije kreiranja prijevoda'
TRANSLATEALLPERMISSION: 'Prevedi u sve dostupne jezike'
TRANSLATEPERMISSION: 'Prevedi %s'
TRANSLATEVIEWLANGS: 'Pogledaj padajući izbornik jezika'
TRANSLATIONS: Prijevodi
Translatable_Transform:
CheckboxValueNo: Ne
CheckboxValueYes: Da
OriginalCheckboxLabel: 'Original: {value}'
OriginalFieldLabel: 'Original {title}'

View File

@ -19,5 +19,6 @@ it:
TRANSLATIONS: Traduzioni
Translatable_Transform:
CheckboxValueNo: 'No'
CheckboxValueYes: Si
OriginalCheckboxLabel: 'Originale: {value}'
OriginalFieldLabel: 'Originale {title}'

View File

@ -4,18 +4,18 @@ ja:
CMSMain_left:
GO: 実行
Form:
LANGAOTHER: '他の言語'
LANGAVAIL: '利用可能な言語'
LANGAOTHER: 他の言語
LANGAVAIL: 利用可能な言語
Translatable:
ALLCREATED: '許可された翻訳全てが作成されました。'
CREATE: '新しい翻訳を行う'
CREATE: 新しい翻訳を行う
CREATEBUTTON: 作成
EXISTING: '現存中の翻訳'
NEWLANGUAGE: '新しい言語'
EXISTING: 現存中の翻訳
NEWLANGUAGE: 新しい言語
NOTICENEWPAGE: '翻訳を作成する前にこのページを保存してください'
TRANSLATEALLPERMISSION: '全ての利用可能言語に翻訳'
TRANSLATEPERMISSION: '%sを翻訳'
TRANSLATEVIEWLANGS: '言語ドロップダウンを表示'
TRANSLATEVIEWLANGS: 言語ドロップダウンを表示
TRANSLATIONS: 翻訳
Translatable_Transform:
OriginalCheckboxLabel: 'オリジナル: {value}'

View File

@ -16,7 +16,7 @@ mi:
TRANSLATEALLPERMISSION: 'Whakamāoritia ki ngā reo katoa e wātea ana'
TRANSLATEPERMISSION: 'Whakamāoritia a %s'
TRANSLATEVIEWLANGS: 'Tirohia te takaiho reo'
TRANSLATIONS: Ngā whakamāoritanga
TRANSLATIONS: 'Ngā whakamāoritanga'
Translatable_Transform:
OriginalCheckboxLabel: 'Taketake: {value}'
OriginalFieldLabel: '{title} taketake'

20
lang/nl_NL.yml Normal file
View File

@ -0,0 +1,20 @@
nl_NL:
CMSMain:
LANGUAGEDROPDOWNLABEL: Taal
CMSMain_left:
GO: Gaan
Form:
LANGAOTHER: 'Andere talen'
LANGAVAIL: 'Beschikbare talen'
Translatable:
ALLCREATED: 'Alle toegestane vertalingen werden gecreëerd.'
CREATE: 'Nieuwe vertaling creëren'
CREATEBUTTON: Creëren
EXISTING: 'Bestaande vertalingen'
NEWLANGUAGE: 'Nieuwe taal'
TRANSLATEALLPERMISSION: 'Vertaal in alle beschikbare talen'
TRANSLATEPERMISSION: 'Vertaal %s'
TRANSLATIONS: Vertalingen
Translatable_Transform:
CheckboxValueNo: Neen
CheckboxValueYes: Ja

24
lang/ru.yml Normal file
View File

@ -0,0 +1,24 @@
ru:
CMSMain:
LANGUAGEDROPDOWNLABEL: Язык
CMSMain_left:
GO: Выполн.
Form:
LANGAOTHER: 'Другие языки'
LANGAVAIL: 'Доступные языки'
Translatable:
ALLCREATED: 'Все переводы на доступные языки созданы.'
CREATE: 'Создать новый перевод'
CREATEBUTTON: Создать
EXISTING: 'Существующие переводы'
NEWLANGUAGE: 'Добавить язык'
NOTICENEWPAGE: 'Пожалуйста, сохраните данную страницу прежде чем создавать перевод'
TRANSLATEALLPERMISSION: 'Перевести на все доступные языки'
TRANSLATEPERMISSION: 'Перевести %s'
TRANSLATEVIEWLANGS: 'Отобразить языковое выпадающее меню'
TRANSLATIONS: Переводы
Translatable_Transform:
CheckboxValueNo: Нет
CheckboxValueYes: Да
OriginalCheckboxLabel: 'Оригинальное значение: {value}'
OriginalFieldLabel: 'Оригинальное {title}'

View File

@ -18,7 +18,7 @@ sk:
TRANSLATEVIEWLANGS: 'Zobraziť zoznam jazykov'
TRANSLATIONS: Preklady
Translatable_Transform:
CheckboxValueNo: 'Nie'
CheckboxValueYes: 'Áno'
CheckboxValueNo: Nie
CheckboxValueYes: Áno
OriginalCheckboxLabel: 'Pôvodné: {value}'
OriginalFieldLabel: 'Pôvodné {title}'

View File

@ -18,7 +18,7 @@ sk_SK:
TRANSLATEVIEWLANGS: 'Zobraziť jazykový rozbaľovací zoznam'
TRANSLATIONS: Preklady
Translatable_Transform:
CheckboxValueNo: 'Nie'
CheckboxValueYes: 'Áno'
CheckboxValueNo: Nie
CheckboxValueYes: Áno
OriginalCheckboxLabel: 'Pôvodné: {value}'
OriginalFieldLabel: 'Pôvodné {title}'

View File

@ -18,5 +18,7 @@ sv:
TRANSLATEVIEWLANGS: 'Visa språk listan'
TRANSLATIONS: Översättningar
Translatable_Transform:
CheckboxValueNo: Nej
CheckboxValueYes: Ja
OriginalCheckboxLabel: 'Original: {value}'
OriginalFieldLabel: 'Original {title}'

View File

@ -18,7 +18,7 @@ tr:
TRANSLATEVIEWLANGS: 'Mevcut dilleri görebilir'
TRANSLATIONS: Çeviriler
Translatable_Transform:
CheckboxValueNo: 'Hayır'
CheckboxValueYes: 'Evet'
CheckboxValueNo: Hayır
CheckboxValueYes: Evet
OriginalCheckboxLabel: 'Orijinal: {value}'
OriginalFieldLabel: 'Orijinal {title}'

View File

@ -1,6 +1,6 @@
vi_VN:
CMSMain:
LANGUAGEDROPDOWNLABEL: Ngôn ngữ
LANGUAGEDROPDOWNLABEL: 'Ngôn ngữ'
CMSMain_left:
GO: Đi
Form:
@ -16,7 +16,7 @@ vi_VN:
TRANSLATEALLPERMISSION: 'Dịch sang mọi ngôn gữ có th'
TRANSLATEPERMISSION: 'Dịch %s'
TRANSLATEVIEWLANGS: 'Xem danh sách ngôn ng'
TRANSLATIONS: Dịch thuật
TRANSLATIONS: 'Dịch thuật'
Translatable_Transform:
OriginalCheckboxLabel: 'Mặc định :{value}'
OriginalFieldLabel: 'Mặc định:{title}'

View File

@ -5,17 +5,17 @@ zh:
GO: 前往
Form:
LANGAOTHER: '其它语言'
LANGAVAIL: '可用的语言'
LANGAVAIL: 可用的语言
Translatable:
ALLCREATED: '所有允许的翻译均已创建。'
CREATE: '创建新的翻译'
CREATE: 创建新的翻译
CREATEBUTTON: 创建
EXISTING: '现存的翻译'
NEWLANGUAGE: '新语言'
EXISTING: 现存的翻译
NEWLANGUAGE: 新语言
NOTICENEWPAGE: '创建翻译前,请先保存本页面。'
TRANSLATEALLPERMISSION: '翻译成所有可用语言'
TRANSLATEALLPERMISSION: 翻译成所有可用语言
TRANSLATEPERMISSION: '翻译 %s'
TRANSLATEVIEWLANGS: '查看语言下拉菜单'
TRANSLATEVIEWLANGS: 查看语言下拉菜单
TRANSLATIONS: 翻译
Translatable_Transform:
OriginalCheckboxLabel: '原文:{value}'

View File

@ -22,6 +22,9 @@ class TranslatableSiteConfigTest extends SapphireTest {
$this->origLocale = Translatable::default_locale();
Translatable::set_default_locale("en_US");
// Delete any default records created outside of fixtures
SiteConfig::get()->exclude('ID', $this->allFixtureIDs('SiteConfig'))->removeAll();
}
function tearDown() {

View File

@ -460,6 +460,31 @@ class TranslatableTest extends FunctionalTest {
Translatable::set_current_locale('en_US');
}
public function testMultibyteUrlsWorkWhenTranslated()
{
Config::inst()->update('URLSegmentFilter', 'default_allow_multibyte', true);
$page = new Page();
$page->URLSegment = 'schön-döner';
$page->Content = 'Kebabs in Berlin are amazing.';
$page->write();
$page->doPublish();
$translatedPage = $page->createTranslation('de_DE');
$translatedPage->Content = 'Döner in Berlin sind unglaublich';
$translatedPage->doPublish();
$this->assertSame('schön-döner-de-de', rawurldecode($translatedPage->URLSegment));
// Test pinging the page on the frontend
$pageResult = $this->get('schön-döner');
$this->assertEquals(200, $pageResult->getStatusCode());
$this->assertContains('Kebabs in Berlin', (string) $pageResult->getBody());
$translatedPageResult = $this->get('schön-döner-de-de');
$this->assertEquals(200, $translatedPageResult->getStatusCode());
$this->assertContains('Döner in Berlin', (string) $translatedPageResult->getBody());
}
function testUpdateCMSFieldsOnSiteTree() {
$pageOrigLang = new TranslatableTest_Page();
$pageOrigLang->write();