Compare commits

...

36 Commits
2.2.6 ... 2

Author SHA1 Message Date
Steve Boyd ed155503d2 Merge branch '2.4' into 2 2021-01-02 11:32:40 +13:00
Steve Boyd 8fee2b2372 Merge branch '2.3' into 2.4 2021-01-02 11:31:18 +13:00
Steve Boyd 6a191b09f9 Merge branch '2.2' into 2.3 2021-01-02 11:30:41 +13:00
Maxime Rainville d168dc7830 Merge branch '2.1' into 2.2 2020-10-15 17:35:15 +13:00
Sam Minnee 97379fc92b MNT: Fix invalid composer.json casing 2020-10-11 16:23:45 +13:00
Sam Minnee ae1155cd04 MNT: Fix invalid composer.json casing 2020-10-11 16:22:57 +13:00
Ingo Schommer a8385e1f43
Merge pull request #286 from open-sausages/pulls/2/warning-of-imminent-anarchy
DOC Add a warnign about support for translatable
2020-08-10 13:18:37 +12:00
Maxime Rainville 23a6c875e6 DOC Add a warnign about support for translatable 2020-08-10 11:54:43 +12:00
Aaron Carlino bed7d9a068
META: Add github action to build docs 2019-12-19 13:49:38 +13:00
Aaron Carlino 2f4fc13743
Merge pull request #284 from silverstripe/pulls/2.1/new-docs
Update userguide for compliance with new docs site
2019-12-19 12:43:34 +13:00
Aaron Carlino 9b89384aa2 Update userguide for compliance with new docs site 2019-12-06 15:03:34 +13:00
Guy Marriott 7806356ddc
Merge branch '2.3' into 2.4 2019-08-01 11:08:29 +12:00
Robbie Averill a353d52372 Merge branch '2.4' into 2 2019-07-23 15:40:03 +02:00
Robbie Averill bff0c63b4f Remove obsolete branch alias 2019-07-23 15:39:17 +02:00
Robbie Averill f761674834 Merge branch '2.3' into 2.4 2019-07-23 15:38:42 +02:00
Robbie Averill 78694caff3 Update Travis builds to include PHP 7 2019-07-23 15:36:05 +02:00
Robbie Averill 220e49271c Merge branch '2.2' into 2.3 2019-07-23 15:33:51 +02:00
Guy Marriott 34e5b0bc60
Merge pull request #283 from creative-commoners/pulls/2.3/multibyte-urls
FIX Translatable now handles multibute URLs when they are enabled
2019-04-05 16:07:38 +13:00
Robbie Averill c09866f586 FIX Translatable now handles multibute URLs when they are enabled 2019-04-05 14:29:03 +13:00
Robbie Averill 43b44f4800
Merge pull request #281 from wernerkrauss/patch-1
Updating links to transifex and docs
2018-08-28 17:31:44 +12:00
wernerkrauss 66593d8bb3
Updating links to transifex and docs
Doc link was broken
2018-08-28 07:21:28 +02:00
Guy 4cf60e9393
Merge remote-tracking branch 'origin/2.2' into 2.3 2018-06-19 10:09:17 +12:00
Robbie Averill 9c8609f788
Merge pull request #280 from creative-commoners/pulls/master/add-supported-module-badge
Add supported module badge to readme
2018-06-18 10:42:19 +12:00
Dylan Wagstaff ec34959baa Add supported module badge to readme 2018-06-15 17:50:48 +12:00
Damian Mooyman 603abfe1d6
Merge pull request #279 from creative-commoners/pulls/2.2/fix-invalid-stage-pt2
BUG Fix invalid stage being specified for queried records
2018-06-13 09:28:24 +12:00
Guy 6a6bc6d677 BUG Fix invalid stage being specified for queried records 2018-06-12 15:16:33 +12:00
Robbie Averill b8d794a5c2
Merge pull request #278 from creative-commoners/pulls/2.2/fix-invalid-stage
BUG Fix invalid stage being specified for queried records
2018-06-12 09:16:07 +12:00
Damian Mooyman bea626eba3
BUG Fix invalid stage being specified for queried records 2018-06-11 15:08:34 +12:00
Robbie Averill 50f145a891 Merge branch '2.2' into 2.3 2018-04-20 16:36:23 +12:00
Robbie Averill dfa1c965a5 Update branch alias for 2.4.x-dev 2018-02-22 10:27:17 +13:00
Robbie Averill 2c81a62b00 Update translations 2018-02-22 09:28:36 +13:00
Robbie Averill 99dd1012b6 Remove obsolete branch-alias 2018-02-22 09:25:13 +13:00
Will Rossiter 4ef5d462dd Merge pull request #266 from micahsheets/2.2
Add default hreflang tag for pages without translations.
2017-09-26 10:52:58 +13:00
Micah Sheets 62523e23df Update Translatable.php 2017-08-15 10:06:38 +12:00
Damian Mooyman 345bb7a0ec Merge branch '2.2' into 2 2016-05-19 13:55:51 +12:00
Damian Mooyman d9f88049d6 Alias 2 branch as 2.3 2016-05-19 12:03:42 +12:00
8 changed files with 128 additions and 75 deletions

14
.github/workflows/main.yml vendored Normal file
View File

@ -0,0 +1,14 @@
name: Build Docs
on:
push:
branches:
- '2.1'
paths:
- 'docs/en/userguide/**'
jobs:
build:
name: build-docs
runs-on: ubuntu-latest
steps:
- name: Run build hook
run: curl -X POST -d {} https://api.netlify.com/build_hooks/${{ secrets.NETLIFY_BUILD_HOOK }}

View File

@ -1,27 +1,26 @@
# See https://github.com/silverstripe-labs/silverstripe-travis-support for setup details
# See https://github.com/silverstripe/silverstripe-travis-support for setup details
language: php
php:
- 5.6
env:
- DB=MYSQL CORE_RELEASE=3
dist: trusty
matrix:
include:
- php: 5.6
env: DB=PGSQL CORE_RELEASE=3
- php: 5.6
env: DB=MYSQL CORE_RELEASE=3
- php: '7.1'
env: DB=PGSQL CORE_RELEASE=3.7
- php: '7.1'
env: DB=MYSQL CORE_RELEASE=3.7
- php: '7.2'
env: DB=MYSQL CORE_RELEASE=3.7
- php: '7.3'
env: DB=MYSQL CORE_RELEASE=3.7
before_script:
- pear -q install --onlyreqdeps pear/PHP_CodeSniffer
- phpenv rehash
- git clone git://github.com/silverstripe-labs/silverstripe-travis-support.git ~/travis-support
- git clone git://github.com/silverstripe/silverstripe-travis-support.git ~/travis-support
- php ~/travis-support/travis_setup.php --source `pwd` --target ~/builds/ss
- cd ~/builds/ss
script:
- vendor/bin/phpunit translatable/tests/
- phpcs --encoding=utf-8 --tab-width=4 --standard=translatable/tests/phpcs -np translatable
- vendor/bin/phpunit translatable/tests
- vendor/bin/phpcs --encoding=utf-8 --tab-width=4 --standard=translatable/tests/phpcs -np translatable

View File

@ -1,6 +1,13 @@
# IMPORTANT NOTE
Silverstripe Translatable is only compatible with Silverstripe CMS 3. [Silverstripe CMS 3 has entered limited support in June 2018](https://www.silverstripe.org/blog/update-on-silverstripe-5-x/). This means we'll only be fixing critical bugs and security issues for Silverstripe CMS 3 going forward. This applies to _Translatable_ as well.
[`silverstripe/fluent`](https://github.com/tractorcow-farm/silverstripe-fluent) is the recommended alternative for Silverstripe CMS 4.
# Translatable module for SilverStripe CMS #
[![Build Status](https://secure.travis-ci.org/silverstripe/silverstripe-translatable.png?branch=2.1)](http://travis-ci.org/silverstripe/silverstripe-translatable)
[![SilverStripe supported module](https://img.shields.io/badge/silverstripe-supported-0071C4.svg)](https://www.silverstripe.org/software/addons/silverstripe-commercially-supported-module-list/)
## Introduction ##
@ -27,7 +34,7 @@ third party translation interface, transifex.com.
Newly added strings will be periodically uploaded there for translation,
and any new translations will be merged back to the project source code.
Please use [https://www.transifex.com/projects/p/silverstripe-translatable/](https://www.transifex.com/projects/p/silverstripe-translatable/) to contribute translations,
Please use [https://www.transifex.com/silverstripe/silverstripe-translatable/](https://www.transifex.com/projects/p/silverstripe-translatable/) to contribute translations,
rather than sending pull requests with YAML files.
See the ["i18n" topic](http://doc.silverstripe.org/framework/en/trunk/topics/i18n) on doc.silverstripe.org for more details.
See the ["i18n" topic](https://docs.silverstripe.org/en/3/developer_guides/i18n/) on doc.silverstripe.org for more details.

View File

@ -933,13 +933,7 @@ class Translatable extends DataExtension implements PermissionProvider {
// This is to prevent the overhead of writing all translations when
// the class didn't actually change.
$baseDataClass = ClassInfo::baseDataClass($this->owner->class);
$currentStage = Versioned::current_stage();
$fresh = Versioned::get_one_by_stage(
$baseDataClass,
Versioned::current_stage(),
'"'.$baseDataClass.'"."ID" = ' . $this->owner->ID,
null
);
$fresh = DataObject::get($baseDataClass)->byId($this->owner->ID);
if ($fresh) {
$changed = $changedFields['ClassName']['after'] != $fresh->ClassName;
}
@ -1300,20 +1294,16 @@ class Translatable extends DataExtension implements PermissionProvider {
// exclude the language of the current owner
$filter .= sprintf(' AND "%s"."Locale" != \'%s\'', $baseDataClass, $this->owner->Locale);
}
$currentStage = Versioned::current_stage();
$joinOnClause = sprintf('"%s_translationgroups"."OriginalID" = "%s"."ID"', $baseDataClass, $baseDataClass);
if($this->owner->hasExtension("Versioned")) {
if($stage) Versioned::reading_stage($stage);
if($this->owner->hasExtension("Versioned") && $stage) {
$translations = Versioned::get_by_stage(
$baseDataClass,
Versioned::current_stage(),
$stage,
$filter,
null
)->leftJoin("{$baseDataClass}_translationgroups", $joinOnClause);
if($stage) Versioned::reading_stage($currentStage);
} else {
$class = $this->owner->class;
$translations = $baseDataClass::get()
$translations = DataObject::get($baseDataClass)
->where($filter)
->leftJoin("{$baseDataClass}_translationgroups", $joinOnClause);
}
@ -1483,6 +1473,11 @@ class Translatable extends DataExtension implements PermissionProvider {
$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
if(Config::inst()->get('Translatable', 'enforce_global_unique_urls')) {
$newTranslation->URLSegment = $urlSegment . '-' . i18n::convert_rfc1766($locale);
@ -1591,6 +1586,22 @@ class Translatable extends DataExtension implements PermissionProvider {
);
}
}
else {
// Added to comply with current Google recommendations
// If no translations found for this page, add a self referencing hreflang tag so Google does not complain
// Language and Local tag
$tags .= sprintf($template,
Convert::raw2xml($this->owner->Title),
i18n::convert_rfc1766($this->owner->Locale),
$this->owner->AbsoluteLink()
);
// Language only tag
$tags .= sprintf($template,
Convert::raw2xml($this->owner->Title),
i18n::get_lang_from_locale($this->owner->Locale),
$this->owner->AbsoluteLink()
);
}
}
function providePermissions() {

View File

@ -1,44 +1,39 @@
{
"name": "silverstripe/translatable",
"type": "silverstripe-module",
"description": "Allows translation of DataObject and SiteTree records into multiple languages ",
"keywords": [
"silverstripe",
"cms",
"i18n",
"localization",
"globalization"
],
"license": "BSD-3-Clause",
"homepage": "https://github.com/silverstripe/silverstripe-translatable/",
"authors": [
{
"name": "Ingo Schommer",
"homepage": "http://chillu.com",
"email": "ingo@silverstripe.com"
}
],
"require": {
"php": ">=5.3.2",
"silverstripe/framework": "~3.2",
"silverstripe/cms": "~3.2"
},
"require-dev": {
"silverstripe/postgresql": "*",
"silverstripe/sqlite3": "*",
"silverstripe/mssql": "*",
"phpunit/PHPUnit": "~3.7@stable"
},
"extra": {
"screenshots": [
"http://www.silverstripe.org/assets/Uploads/translatable4-small.png"
],
"branch-alias": {
"2.x-dev": "2.2.x-dev"
}
},
"support": {
"issues": "https://github.com/silverstripe/silverstripe-translatable/issues?state=open"
},
"minimum-stability": "dev"
"name": "silverstripe/translatable",
"type": "silverstripe-module",
"description": "Allows translation of DataObject and SiteTree records into multiple languages ",
"keywords": [
"silverstripe",
"cms",
"i18n",
"localization",
"globalization"
],
"license": "BSD-3-Clause",
"homepage": "https://github.com/silverstripe/silverstripe-translatable/",
"authors": [
{
"name": "Ingo Schommer",
"homepage": "http://chillu.com",
"email": "ingo@silverstripe.com"
}
],
"require": {
"php": ">=5.3.2",
"silverstripe/framework": "~3.2",
"silverstripe/cms": "~3.2"
},
"require-dev": {
"phpunit/phpunit": "^5.7",
"squizlabs/php_codesniffer": "^3.0"
},
"extra": {
"screenshots": [
"http://www.silverstripe.org/assets/Uploads/translatable4-small.png"
]
},
"support": {
"issues": "https://github.com/silverstripe/silverstripe-translatable/issues?state=open"
},
"minimum-stability": "dev"
}

View File

@ -2,11 +2,11 @@
The SilverStripe Translatable module allows you to create and edit multiple pages in various languages. This module also adds the ability for your users to select which language of a page they wish to view.
<div class="note" markdown="1">
[note]
Notes:
The SilverStripe Translatable module does not translate content automatically, content authors will need to enter the translated content manually for each translated page.
</div>
[/note]
To begin translating content select a page in your site tree from the "Pages" admin. You can see in the below image:

View File

@ -1,5 +1,7 @@
---
title: Working with translations
summary: Adding translated content to your website.
---
# Working with translations

View File

@ -459,7 +459,32 @@ class TranslatableTest extends FunctionalTest {
Config::inst()->update('Translatable', 'enforce_global_unique_urls', true);
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() {
$pageOrigLang = new TranslatableTest_Page();
$pageOrigLang->write();