Merge remote-tracking branch 2.0 into 2.1

Conflicts:
	.travis.yml
	README.md
	composer.json
This commit is contained in:
Daniel Hensby 2015-11-03 21:40:29 +00:00
commit 59a9d4d06e
11 changed files with 145 additions and 34 deletions

View File

@ -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);
}
/**

View File

@ -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 {
'<li><a href="%s">%s</a></li>',
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

View File

@ -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

View File

@ -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();
}
});

View File

@ -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}'

18
lang/fa_IR.yml Normal file
View File

@ -0,0 +1,18 @@
fa_IR:
CMSMain:
LANGUAGEDROPDOWNLABEL: زبان
CMSMain_left:
GO: برو
Form:
LANGAOTHER: 'زبان های دیگر'
LANGAVAIL: 'زبان های موجود'
Translatable:
ALLCREATED: 'همه ترجمه ها اجازه داده شده ایجاد شده است.'
CREATE: 'ایجاد ترجمه جدید'
CREATEBUTTON: ایجاد
EXISTING: 'ترجمه های موجود'
NEWLANGUAGE: 'زبان جدید'
NOTICENEWPAGE: 'لطفا قبل از ایجاد یک ترجمه این صفحه را ذخیره کنید'
TRANSLATEALLPERMISSION: 'ترجمه به تمام زبان های موجود'
TRANSLATEVIEWLANGS: 'نمایش منوی زبان'
TRANSLATIONS: ترجمه

View File

@ -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}'

22
lang/pt_PT.yml Normal file
View File

@ -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}'

22
lang/sr@latin.yml Normal file
View File

@ -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}'

22
lang/sr_RS@latin.yml Normal file
View File

@ -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}'

18
lang/tr.yml Normal file
View File

@ -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}'