mirror of
https://github.com/silverstripe/silverstripe-translatable
synced 2024-10-22 11:05:59 +02:00
FIX Translatable now handles multibute URLs when they are enabled
This commit is contained in:
parent
4cf60e9393
commit
c09866f586
@ -1473,6 +1473,11 @@ class Translatable extends DataExtension implements PermissionProvider {
|
|||||||
$urlSegment = $newTranslation->URLSegment;
|
$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
|
// Only make segment unique if it should be enforced
|
||||||
if(Config::inst()->get('Translatable', 'enforce_global_unique_urls')) {
|
if(Config::inst()->get('Translatable', 'enforce_global_unique_urls')) {
|
||||||
$newTranslation->URLSegment = $urlSegment . '-' . i18n::convert_rfc1766($locale);
|
$newTranslation->URLSegment = $urlSegment . '-' . i18n::convert_rfc1766($locale);
|
||||||
|
@ -460,6 +460,31 @@ class TranslatableTest extends FunctionalTest {
|
|||||||
Translatable::set_current_locale('en_US');
|
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() {
|
function testUpdateCMSFieldsOnSiteTree() {
|
||||||
$pageOrigLang = new TranslatableTest_Page();
|
$pageOrigLang = new TranslatableTest_Page();
|
||||||
$pageOrigLang->write();
|
$pageOrigLang->write();
|
||||||
|
Loading…
Reference in New Issue
Block a user