mirror of
https://github.com/silverstripe/silverstripe-translatable
synced 2024-10-22 11:05:59 +02:00
Merge remote-tracking branch 2.0 into 2.1
Conflicts: .travis.yml README.md composer.json
This commit is contained in:
commit
59a9d4d06e
@ -16,9 +16,6 @@ class TranslatableCMSMainExtension extends Extension {
|
|||||||
// as an intermediary rather than the endpoint controller
|
// as an intermediary rather than the endpoint controller
|
||||||
if(!$this->owner->stat('tree_class')) return;
|
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,
|
// Locale" attribute is either explicitly added by LeftAndMain Javascript logic,
|
||||||
// or implied on a translated record (see {@link Translatable->updateCMSFields()}).
|
// or implied on a translated record (see {@link Translatable->updateCMSFields()}).
|
||||||
// $Lang serves as a "context" which can be inspected by Translatable - hence it
|
// $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');
|
$id = $req->param('ID');
|
||||||
if($req->requestVar("Locale")) {
|
if($req->requestVar("Locale")) {
|
||||||
$this->owner->Locale = $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)) {
|
} else if($id && is_numeric($id)) {
|
||||||
$record = DataObject::get_by_id($this->owner->stat('tree_class'), $id);
|
$record = DataObject::get_by_id($this->owner->stat('tree_class'), $id);
|
||||||
if($record && $record->Locale) $this->owner->Locale = $record->Locale;
|
if($record && $record->Locale) $this->owner->Locale = $record->Locale;
|
||||||
@ -50,16 +45,14 @@ class TranslatableCMSMainExtension extends Extension {
|
|||||||
}
|
}
|
||||||
Translatable::set_current_locale($this->owner->Locale);
|
Translatable::set_current_locale($this->owner->Locale);
|
||||||
|
|
||||||
// if a locale is set, it needs to match to the current record
|
// If a locale is set, it needs to match to the current record
|
||||||
if($req->requestVar("Locale")) {
|
|
||||||
$requestLocale = $req->requestVar("Locale");
|
$requestLocale = $req->requestVar("Locale");
|
||||||
} else {
|
|
||||||
$requestLocale = $req->requestVar("locale");
|
|
||||||
}
|
|
||||||
|
|
||||||
$page = $this->owner->currentPage();
|
$page = $this->owner->currentPage();
|
||||||
if(
|
if(
|
||||||
$requestLocale && $page && $page->hasExtension('Translatable')
|
$req->httpMethod() == 'GET' // leave form submissions alone
|
||||||
|
&& $requestLocale
|
||||||
|
&& $page
|
||||||
|
&& $page->hasExtension('Translatable')
|
||||||
&& $page->Locale != $requestLocale
|
&& $page->Locale != $requestLocale
|
||||||
&& $req->latestParam('Action') != 'EditorToolbar'
|
&& $req->latestParam('Action') != 'EditorToolbar'
|
||||||
) {
|
) {
|
||||||
@ -75,7 +68,7 @@ class TranslatableCMSMainExtension extends Extension {
|
|||||||
// If the record is not translated, redirect to pages overview
|
// If the record is not translated, redirect to pages overview
|
||||||
return $this->owner->redirect(Controller::join_links(
|
return $this->owner->redirect(Controller::join_links(
|
||||||
singleton('CMSPagesController')->Link(),
|
singleton('CMSPagesController')->Link(),
|
||||||
'?locale=' . $requestLocale
|
'?Locale=' . $requestLocale
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -140,12 +133,12 @@ class TranslatableCMSMainExtension extends Extension {
|
|||||||
|
|
||||||
function updateLink(&$link) {
|
function updateLink(&$link) {
|
||||||
$locale = $this->owner->Locale ? $this->owner->Locale : Translatable::get_current_locale();
|
$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) {
|
function updateLinkWithSearch(&$link) {
|
||||||
$locale = $this->owner->Locale ? $this->owner->Locale : Translatable::get_current_locale();
|
$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) {
|
function updateExtraTreeTools(&$html) {
|
||||||
@ -155,7 +148,7 @@ class TranslatableCMSMainExtension extends Extension {
|
|||||||
|
|
||||||
function updateLinkPageAdd(&$link) {
|
function updateLinkPageAdd(&$link) {
|
||||||
$locale = $this->owner->Locale ? $this->owner->Locale : Translatable::get_current_locale();
|
$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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -212,6 +212,21 @@ class Translatable extends DataExtension implements PermissionProvider {
|
|||||||
*/
|
*/
|
||||||
private static $enforce_global_unique_urls = true;
|
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
|
* 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>',
|
'<li><a href="%s">%s</a></li>',
|
||||||
Controller::join_links(
|
Controller::join_links(
|
||||||
$existingTranslation->CMSEditLink(),
|
$existingTranslation->CMSEditLink(),
|
||||||
'?locale=' . $existingTranslation->Locale
|
'?Locale=' . $existingTranslation->Locale
|
||||||
),
|
),
|
||||||
i18n::get_locale_name($existingTranslation->Locale)
|
i18n::get_locale_name($existingTranslation->Locale)
|
||||||
);
|
);
|
||||||
@ -1150,15 +1165,8 @@ class Translatable extends DataExtension implements PermissionProvider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO Remove hardcoding for SiteTree properties
|
// Get excluded fields from translation
|
||||||
$excludeFields = array(
|
$excludeFields = $this->owner->config()->translate_excluded_fields;
|
||||||
'ViewerGroups',
|
|
||||||
'EditorGroups',
|
|
||||||
'CanViewType',
|
|
||||||
'CanEditType',
|
|
||||||
'NewTransLang',
|
|
||||||
'createtranslation'
|
|
||||||
);
|
|
||||||
|
|
||||||
// if a language other than default language is used, we're in "translation mode",
|
// if a language other than default language is used, we're in "translation mode",
|
||||||
// hence have to modify the original fields
|
// hence have to modify the original fields
|
||||||
|
@ -37,10 +37,10 @@
|
|||||||
},
|
},
|
||||||
onchange: function(e) {
|
onchange: function(e) {
|
||||||
// Get new locale code
|
// Get new locale code
|
||||||
locale = {locale: $(e.target).val()};
|
var locale = {Locale: $(e.target).val()};
|
||||||
|
|
||||||
// Check existing url
|
// Check existing url
|
||||||
search = /locale=[^&]*/;
|
search = /Locale=[^&]*/;
|
||||||
url = document.location.href;
|
url = document.location.href;
|
||||||
if(url.match(search)) {
|
if(url.match(search)) {
|
||||||
// Replace locale code
|
// Replace locale code
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
onchange: function(e) {
|
onchange: function(e) {
|
||||||
// reload tree with selected locale
|
// reload tree with selected locale
|
||||||
var treeDropdown = $(this).parents('form').find('#internal .treedropdown');
|
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();
|
treeDropdown.loadTree();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -18,7 +18,7 @@ en:
|
|||||||
TRANSLATEVIEWLANGS: 'View language dropdown'
|
TRANSLATEVIEWLANGS: 'View language dropdown'
|
||||||
TRANSLATIONS: Translations
|
TRANSLATIONS: Translations
|
||||||
Translatable_Transform:
|
Translatable_Transform:
|
||||||
CheckboxValueNo: No
|
CheckboxValueNo: 'No'
|
||||||
CheckboxValueYes: Yes
|
CheckboxValueYes: 'Yes'
|
||||||
OriginalCheckboxLabel: 'Original: {value}'
|
OriginalCheckboxLabel: 'Original: {value}'
|
||||||
OriginalFieldLabel: 'Original {title}'
|
OriginalFieldLabel: 'Original {title}'
|
||||||
|
18
lang/fa_IR.yml
Normal file
18
lang/fa_IR.yml
Normal 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: ترجمه
|
12
lang/id.yml
12
lang/id.yml
@ -5,10 +5,18 @@ id:
|
|||||||
GO: Lanjut
|
GO: Lanjut
|
||||||
Form:
|
Form:
|
||||||
LANGAOTHER: 'Bahasa lain'
|
LANGAOTHER: 'Bahasa lain'
|
||||||
LANGAVAIL: 'Bahasa yang tersedia'
|
LANGAVAIL: 'Bahasa tersedia'
|
||||||
Translatable:
|
Translatable:
|
||||||
|
ALLCREATED: 'Semua bahasa yang diperbolehkan sudah dibuat.'
|
||||||
CREATE: 'Buat terjemahan baru'
|
CREATE: 'Buat terjemahan baru'
|
||||||
CREATEBUTTON: Buat
|
CREATEBUTTON: Buat
|
||||||
EXISTING: 'Terjemahan yang ada'
|
EXISTING: 'Terjemahan yang ada'
|
||||||
NEWLANGUAGE: 'Bahasa baru'
|
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
22
lang/pt_PT.yml
Normal 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
22
lang/sr@latin.yml
Normal 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
22
lang/sr_RS@latin.yml
Normal 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
18
lang/tr.yml
Normal 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}'
|
Loading…
Reference in New Issue
Block a user