diff --git a/code/controller/TranslatableCMSMainExtension.php b/code/controller/TranslatableCMSMainExtension.php index 7f5778f..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 @@ -26,8 +23,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; @@ -50,16 +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"); - } else { - $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' ) { @@ -75,7 +68,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 +133,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 +148,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 4975da3..51e8dec 100755 --- a/code/model/Translatable.php +++ b/code/model/Translatable.php @@ -212,6 +212,21 @@ class Translatable extends DataExtension implements PermissionProvider { */ 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 */ @@ -1104,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) ); @@ -1150,15 +1165,8 @@ class Translatable extends DataExtension implements PermissionProvider { } } - // 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 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(); } }); 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/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}' 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}'