From f2a017a21cdc16fef32dc35e0c167173215fd4f0 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Wed, 29 Apr 2015 18:54:26 +1200 Subject: [PATCH 1/7] Limit compat to 3.1 No longer compatible with 3.2 or higher due to deprecation warnings on has_one() vs hasOne(). --- .travis.yml | 5 ----- README.md | 2 +- composer.json | 4 ++-- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index e2e6bf3..77e8776 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,11 +8,6 @@ php: env: - DB=MYSQL CORE_RELEASE=3.1 -matrix: - include: - - php: 5.4 - env: DB=MYSQL CORE_RELEASE=3 - before_script: - pear -q install --onlyreqdeps pear/PHP_CodeSniffer - phpenv rehash diff --git a/README.md b/README.md index e7ee313..aa75431 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Note: This module was originally part of the SilverStripe CMS 2.x codebase. ## Requirements ## - * SilverStripe Framework 3.1+ and CMS 3.1+ + * SilverStripe Framework 3.1 and CMS 3.1 ## Maintainers ## diff --git a/composer.json b/composer.json index 594557f..b15f4a1 100644 --- a/composer.json +++ b/composer.json @@ -15,8 +15,8 @@ "require": { "php": ">=5.3.2", - "silverstripe/framework": "~3.1", - "silverstripe/cms": "~3.1" + "silverstripe/framework": "3.1.*", + "silverstripe/cms": "3.1.*" }, "require-dev": { "silverstripe/postgresql": "*", From f4b41ddd92f9567c913b9878b9344df605dbdf47 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Wed, 29 Apr 2015 19:19:15 +1200 Subject: [PATCH 2/7] Updated Travis build status branch --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index aa75431..32c85c7 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Translatable module for SilverStripe CMS # -[![Build Status](https://secure.travis-ci.org/silverstripe/silverstripe-translatable.png?branch=1.1)](http://travis-ci.org/silverstripe/silverstripe-translatable) +[![Build Status](https://secure.travis-ci.org/silverstripe/silverstripe-translatable.png?branch=2.0)](http://travis-ci.org/silverstripe/silverstripe-translatable) ## Introduction ## From 1c76fdbbeebbde5d7af4d61bc1d48239f75beb3e Mon Sep 17 00:00:00 2001 From: Damian Mooyman Date: Tue, 26 May 2015 18:25:18 +1200 Subject: [PATCH 3/7] Update translations --- lang/en.yml | 4 ++-- lang/fa_IR.yml | 18 ++++++++++++++++++ lang/id.yml | 12 ++++++++++-- lang/tr.yml | 18 ++++++++++++++++++ 4 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 lang/fa_IR.yml create mode 100644 lang/tr.yml diff --git a/lang/en.yml b/lang/en.yml index aa30a52..119717f 100644 --- a/lang/en.yml +++ b/lang/en.yml @@ -18,7 +18,7 @@ en: TRANSLATEVIEWLANGS: 'View language dropdown' TRANSLATIONS: Translations Translatable_Transform: - CheckboxValueNo: No - CheckboxValueYes: Yes + CheckboxValueNo: 'No' + CheckboxValueYes: 'Yes' OriginalCheckboxLabel: 'Original: {value}' OriginalFieldLabel: 'Original {title}' diff --git a/lang/fa_IR.yml b/lang/fa_IR.yml new file mode 100644 index 0000000..1588021 --- /dev/null +++ b/lang/fa_IR.yml @@ -0,0 +1,18 @@ +fa_IR: + CMSMain: + LANGUAGEDROPDOWNLABEL: زبان + CMSMain_left: + GO: برو + Form: + LANGAOTHER: 'زبان های دیگر' + LANGAVAIL: 'زبان های موجود' + Translatable: + ALLCREATED: 'همه ترجمه ها اجازه داده شده ایجاد شده است.' + CREATE: 'ایجاد ترجمه جدید' + CREATEBUTTON: ایجاد + EXISTING: 'ترجمه های موجود' + NEWLANGUAGE: 'زبان جدید' + NOTICENEWPAGE: 'لطفا قبل از ایجاد یک ترجمه این صفحه را ذخیره کنید' + TRANSLATEALLPERMISSION: 'ترجمه به تمام زبان های موجود' + TRANSLATEVIEWLANGS: 'نمایش منوی زبان' + TRANSLATIONS: ترجمه diff --git a/lang/id.yml b/lang/id.yml index 1936b8f..72a111a 100644 --- a/lang/id.yml +++ b/lang/id.yml @@ -5,10 +5,18 @@ id: GO: Lanjut Form: LANGAOTHER: 'Bahasa lain' - LANGAVAIL: 'Bahasa yang tersedia' + LANGAVAIL: 'Bahasa tersedia' Translatable: + ALLCREATED: 'Semua bahasa yang diperbolehkan sudah dibuat.' CREATE: 'Buat terjemahan baru' CREATEBUTTON: Buat EXISTING: 'Terjemahan yang ada' NEWLANGUAGE: 'Bahasa baru' - TRANSLATEPERMISSION: 'Terjemahan %s' + NOTICENEWPAGE: 'Mohon simpan laman ini sebelum membuat terjemahan' + TRANSLATEALLPERMISSION: 'Terjemahkan ke semua bahasa tersedia' + TRANSLATEPERMISSION: 'Terjemahkan %s' + TRANSLATEVIEWLANGS: 'Tampilkan pilihan bahasa' + TRANSLATIONS: Terjemahan + Translatable_Transform: + OriginalCheckboxLabel: 'Asli: {value}' + OriginalFieldLabel: 'Asli {title}' diff --git a/lang/tr.yml b/lang/tr.yml new file mode 100644 index 0000000..9e10985 --- /dev/null +++ b/lang/tr.yml @@ -0,0 +1,18 @@ +tr: + CMSMain: + LANGUAGEDROPDOWNLABEL: Lisan + CMSMain_left: + GO: Git + Form: + LANGAOTHER: 'Diğer Lisanlar' + LANGAVAIL: 'Mevcut Lisanlar' + Translatable: + CREATE: 'Yeni çeviri oluştur' + CREATEBUTTON: Oluştur + EXISTING: 'Mevcut Çeviriler' + NEWLANGUAGE: 'Yeni Lisan' + NOTICENEWPAGE: 'Yeni bir çeviri oluşturmadan önce lütfen sayfayı kaydediniz' + TRANSLATIONS: Çeviriler + Translatable_Transform: + OriginalCheckboxLabel: 'Orjinal: {değer}' + OriginalFieldLabel: 'Orjinal {başlık}' From 6aefb2e09fbdad0f3e74f54e916fc7e08d704d33 Mon Sep 17 00:00:00 2001 From: Damian Mooyman Date: Fri, 29 May 2015 15:52:14 +1200 Subject: [PATCH 4/7] BUG Fix compat with userforms/translatable --- code/model/Translatable.php | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/code/model/Translatable.php b/code/model/Translatable.php index 5abdde2..5a6d358 100755 --- a/code/model/Translatable.php +++ b/code/model/Translatable.php @@ -211,6 +211,21 @@ class Translatable extends DataExtension implements PermissionProvider { * or URL path prefixes like "/en/mypage". */ private static $enforce_global_unique_urls = true; + + /** + * Exclude these fields from translation + * + * @var array + * @config + */ + private static $translate_excluded_fields = array( + 'ViewerGroups', + 'EditorGroups', + 'CanViewType', + 'CanEditType', + 'NewTransLang', + 'createtranslation' + ); /** * Reset static configuration variables to their default values @@ -1149,16 +1164,9 @@ class Translatable extends DataExtension implements PermissionProvider { if(is_a($this->owner, $excludedPageType)) return; } } - - // TODO Remove hardcoding for SiteTree properties - $excludeFields = array( - 'ViewerGroups', - 'EditorGroups', - 'CanViewType', - 'CanEditType', - 'NewTransLang', - 'createtranslation' - ); + + // Get excluded fields from translation + $excludeFields = $this->owner->config()->translate_excluded_fields; // if a language other than default language is used, we're in "translation mode", // hence have to modify the original fields From a0a6ec2f913d7bd9e8de8bf8546bb95f8fb570b7 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Mon, 1 Jun 2015 20:52:07 +1200 Subject: [PATCH 5/7] Consistently use uppercase "Locale" GET param Causes inconsistent behaviour between form field name ("Locale") and view state in GET parameters ("Locale" and "locale"). Related to #156. --- code/controller/TranslatableCMSMainExtension.php | 12 ++++-------- code/model/Translatable.php | 2 +- javascript/CMSMain.Translatable.js | 4 ++-- javascript/HtmlEditorField.Translatable.js | 2 +- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/code/controller/TranslatableCMSMainExtension.php b/code/controller/TranslatableCMSMainExtension.php index 7f5778f..77ca390 100644 --- a/code/controller/TranslatableCMSMainExtension.php +++ b/code/controller/TranslatableCMSMainExtension.php @@ -26,8 +26,6 @@ class TranslatableCMSMainExtension extends Extension { $id = $req->param('ID'); if($req->requestVar("Locale")) { $this->owner->Locale = $req->requestVar("Locale"); - } elseif($req->requestVar("locale")) { - $this->owner->Locale = $req->requestVar("locale"); } else if($id && is_numeric($id)) { $record = DataObject::get_by_id($this->owner->stat('tree_class'), $id); if($record && $record->Locale) $this->owner->Locale = $record->Locale; @@ -53,8 +51,6 @@ class TranslatableCMSMainExtension extends Extension { // if a locale is set, it needs to match to the current record if($req->requestVar("Locale")) { $requestLocale = $req->requestVar("Locale"); - } else { - $requestLocale = $req->requestVar("locale"); } $page = $this->owner->currentPage(); @@ -75,7 +71,7 @@ class TranslatableCMSMainExtension extends Extension { // If the record is not translated, redirect to pages overview return $this->owner->redirect(Controller::join_links( singleton('CMSPagesController')->Link(), - '?locale=' . $requestLocale + '?Locale=' . $requestLocale )); } } @@ -140,12 +136,12 @@ class TranslatableCMSMainExtension extends Extension { function updateLink(&$link) { $locale = $this->owner->Locale ? $this->owner->Locale : Translatable::get_current_locale(); - if($locale) $link = Controller::join_links($link, '?locale=' . $locale); + if($locale) $link = Controller::join_links($link, '?Locale=' . $locale); } function updateLinkWithSearch(&$link) { $locale = $this->owner->Locale ? $this->owner->Locale : Translatable::get_current_locale(); - if($locale) $link = Controller::join_links($link, '?locale=' . $locale); + if($locale) $link = Controller::join_links($link, '?Locale=' . $locale); } function updateExtraTreeTools(&$html) { @@ -155,7 +151,7 @@ class TranslatableCMSMainExtension extends Extension { function updateLinkPageAdd(&$link) { $locale = $this->owner->Locale ? $this->owner->Locale : Translatable::get_current_locale(); - if($locale) $link = Controller::join_links($link, '?locale=' . $locale); + if($locale) $link = Controller::join_links($link, '?Locale=' . $locale); } /** diff --git a/code/model/Translatable.php b/code/model/Translatable.php index 5a6d358..dd19233 100755 --- a/code/model/Translatable.php +++ b/code/model/Translatable.php @@ -1119,7 +1119,7 @@ class Translatable extends DataExtension implements PermissionProvider { '
  • %s
  • ', Controller::join_links( $existingTranslation->CMSEditLink(), - '?locale=' . $existingTranslation->Locale + '?Locale=' . $existingTranslation->Locale ), i18n::get_locale_name($existingTranslation->Locale) ); diff --git a/javascript/CMSMain.Translatable.js b/javascript/CMSMain.Translatable.js index 196c17d..161f13c 100755 --- a/javascript/CMSMain.Translatable.js +++ b/javascript/CMSMain.Translatable.js @@ -37,10 +37,10 @@ }, onchange: function(e) { // Get new locale code - locale = {locale: $(e.target).val()}; + var locale = {Locale: $(e.target).val()}; // Check existing url - search = /locale=[^&]*/; + search = /Locale=[^&]*/; url = document.location.href; if(url.match(search)) { // Replace locale code diff --git a/javascript/HtmlEditorField.Translatable.js b/javascript/HtmlEditorField.Translatable.js index 0aec82d..8830659 100644 --- a/javascript/HtmlEditorField.Translatable.js +++ b/javascript/HtmlEditorField.Translatable.js @@ -31,7 +31,7 @@ onchange: function(e) { // reload tree with selected locale var treeDropdown = $(this).parents('form').find('#internal .treedropdown'); - treeDropdown.data('urlTree', $.path.addSearchParams(treeDropdown.data('urlTree').replace(/locale=[^&]*/, ''), 'locale='+$(this).val())); + treeDropdown.data('urlTree', $.path.addSearchParams(treeDropdown.data('urlTree').replace(/Locale=[^&]*/, ''), 'Locale='+$(this).val())); treeDropdown.loadTree(); } }); From da30096d65741198cd4ddbf2afd55a55bed8d906 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Mon, 1 Jun 2015 20:53:53 +1200 Subject: [PATCH 6/7] Set current locale on POST requests (fixes #156) --- code/controller/TranslatableCMSMainExtension.php | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/code/controller/TranslatableCMSMainExtension.php b/code/controller/TranslatableCMSMainExtension.php index 77ca390..8ed5dd3 100644 --- a/code/controller/TranslatableCMSMainExtension.php +++ b/code/controller/TranslatableCMSMainExtension.php @@ -16,9 +16,6 @@ class TranslatableCMSMainExtension extends Extension { // as an intermediary rather than the endpoint controller if(!$this->owner->stat('tree_class')) return; - // Leave form submissions alone - if($req->httpMethod() != 'GET') return; - // Locale" attribute is either explicitly added by LeftAndMain Javascript logic, // or implied on a translated record (see {@link Translatable->updateCMSFields()}). // $Lang serves as a "context" which can be inspected by Translatable - hence it @@ -48,14 +45,14 @@ class TranslatableCMSMainExtension extends Extension { } Translatable::set_current_locale($this->owner->Locale); - // if a locale is set, it needs to match to the current record - if($req->requestVar("Locale")) { - $requestLocale = $req->requestVar("Locale"); - } - + // If a locale is set, it needs to match to the current record + $requestLocale = $req->requestVar("Locale"); $page = $this->owner->currentPage(); if( - $requestLocale && $page && $page->hasExtension('Translatable') + $req->httpMethod() == 'GET' // leave form submissions alone + && $requestLocale + && $page + && $page->hasExtension('Translatable') && $page->Locale != $requestLocale && $req->latestParam('Action') != 'EditorToolbar' ) { From 82c325199141e17b12532d1de23b5965d12df31c Mon Sep 17 00:00:00 2001 From: Damian Mooyman Date: Thu, 20 Aug 2015 12:47:37 +1200 Subject: [PATCH 7/7] Update translations --- lang/pt_PT.yml | 22 ++++++++++++++++++++++ lang/sr@latin.yml | 22 ++++++++++++++++++++++ lang/sr_RS@latin.yml | 22 ++++++++++++++++++++++ 3 files changed, 66 insertions(+) create mode 100644 lang/pt_PT.yml create mode 100644 lang/sr@latin.yml create mode 100644 lang/sr_RS@latin.yml diff --git a/lang/pt_PT.yml b/lang/pt_PT.yml new file mode 100644 index 0000000..d462ff1 --- /dev/null +++ b/lang/pt_PT.yml @@ -0,0 +1,22 @@ +pt_PT: + CMSMain: + LANGUAGEDROPDOWNLABEL: Linguagem + CMSMain_left: + GO: Ir + Form: + LANGAOTHER: 'Outras linguagens' + LANGAVAIL: 'Linguagens disponiveis' + Translatable: + ALLCREATED: 'Todas as traduções disponiveis foram criadas.' + CREATE: 'Criar nova tradução' + CREATEBUTTON: Criar + EXISTING: 'Traduções existentes' + NEWLANGUAGE: 'Nova linguagem' + NOTICENEWPAGE: 'Por favor, guarde esta página antes de criar uma tradução' + TRANSLATEALLPERMISSION: 'Traduz para todas as linguagens disponiveis' + TRANSLATEPERMISSION: 'Traduz %s' + TRANSLATEVIEWLANGS: 'Ver menu da linguagem' + TRANSLATIONS: Traduções + Translatable_Transform: + OriginalCheckboxLabel: 'Original: {value}' + OriginalFieldLabel: 'Original {title}' diff --git a/lang/sr@latin.yml b/lang/sr@latin.yml new file mode 100644 index 0000000..9e1cafe --- /dev/null +++ b/lang/sr@latin.yml @@ -0,0 +1,22 @@ +sr@latin: + CMSMain: + LANGUAGEDROPDOWNLABEL: Jezik + CMSMain_left: + GO: Idi + Form: + LANGAOTHER: 'Drugi jezici' + LANGAVAIL: 'Raspoloživi jezici' + Translatable: + ALLCREATED: 'Svi dozvoljeni prevodi su kreirani.' + CREATE: 'Kreiraj novi prevod' + CREATEBUTTON: Kreiraj + EXISTING: 'Postojeći prevodi' + NEWLANGUAGE: 'Novi jezik' + NOTICENEWPAGE: 'Molimo Vas da pre kreiranja prevoda snimite stranicu' + TRANSLATEALLPERMISSION: 'Prevedi na sve raspoložive jezike' + TRANSLATEPERMISSION: 'Prevedi %s' + TRANSLATEVIEWLANGS: 'Pogledaj padajući meni za izbor jezika' + TRANSLATIONS: Prevodi + Translatable_Transform: + OriginalCheckboxLabel: 'Original: {value}' + OriginalFieldLabel: 'Original {title}' diff --git a/lang/sr_RS@latin.yml b/lang/sr_RS@latin.yml new file mode 100644 index 0000000..f348659 --- /dev/null +++ b/lang/sr_RS@latin.yml @@ -0,0 +1,22 @@ +sr_RS@latin: + CMSMain: + LANGUAGEDROPDOWNLABEL: Jezik + CMSMain_left: + GO: Idi + Form: + LANGAOTHER: 'Ostali jezici' + LANGAVAIL: 'Raspoloživi jezici' + Translatable: + ALLCREATED: 'Svi dozvoljeni prevodi su napravljeni.' + CREATE: 'Napravi novi prevod' + CREATEBUTTON: Napravi + EXISTING: 'Postojeći prevodi' + NEWLANGUAGE: 'Novi jezik' + NOTICENEWPAGE: 'Molimo Vas sačuvajte ovu stranu pre pravljenja prevoda' + TRANSLATEALLPERMISSION: 'Prevedi na sve raspoložive jezike' + TRANSLATEPERMISSION: 'Prevedi %s' + TRANSLATEVIEWLANGS: 'Prikaži listu jezika' + TRANSLATIONS: Prevodi + Translatable_Transform: + OriginalCheckboxLabel: 'Original: {vrednost}' + OriginalFieldLabel: 'Origina {naslov}'