diff --git a/composer.json b/composer.json index f9c31a76..59bc8521 100644 --- a/composer.json +++ b/composer.json @@ -7,6 +7,7 @@ "ext-xml": "*", "ext-pdo": "*", "ext-pdo_mysql": "*", + "ext-json": "*", "leafo/scssphp": "0.7.6", "erusev/parsedown": "^1.6", "erusev/parsedown-extra": "^0.7.1", diff --git a/composer.lock b/composer.lock index cb30b7c2..201ee40b 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "de5f8449179c92b9416b62185db66c94", + "content-hash": "4df89eeabf27a1fde648e75d29109826", "packages": [ { "name": "erusev/parsedown", @@ -200,16 +200,16 @@ }, { "name": "pelago/emogrifier", - "version": "v2.1.1", + "version": "v2.2.0", "source": { "type": "git", "url": "https://github.com/MyIntervals/emogrifier.git", - "reference": "8ee7fb5ad772915451ed3415c1992bd3697d4983" + "reference": "2472bc1c3a2dee8915ecc2256139c6100024332f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/MyIntervals/emogrifier/zipball/8ee7fb5ad772915451ed3415c1992bd3697d4983", - "reference": "8ee7fb5ad772915451ed3415c1992bd3697d4983", + "url": "https://api.github.com/repos/MyIntervals/emogrifier/zipball/2472bc1c3a2dee8915ecc2256139c6100024332f", + "reference": "2472bc1c3a2dee8915ecc2256139c6100024332f", "shasum": "" }, "require": { @@ -227,7 +227,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.1.x-dev" + "dev-master": "3.0.x-dev" } }, "autoload": { @@ -240,16 +240,6 @@ "MIT" ], "authors": [ - { - "name": "John Reeve", - "email": "jreeve@pelagodesign.com" - }, - { - "name": "Cameron Brooks" - }, - { - "name": "Jaime Prado" - }, { "name": "Oliver Klee", "email": "github@oliverklee.de" @@ -258,9 +248,19 @@ "name": "Zoli Szabó", "email": "zoli.szabo+github@gmail.com" }, + { + "name": "John Reeve", + "email": "jreeve@pelagodesign.com" + }, { "name": "Jake Hotson", "email": "jake@qzdesign.co.uk" + }, + { + "name": "Cameron Brooks" + }, + { + "name": "Jaime Prado" } ], "description": "Converts CSS styles into inline style attributes in your HTML code", @@ -270,7 +270,7 @@ "email", "pre-processing" ], - "time": "2018-12-10T10:36:30+00:00" + "time": "2019-09-04T16:07:59+00:00" }, { "name": "symfony/css-selector", @@ -338,7 +338,8 @@ "ext-mbstring": "*", "ext-xml": "*", "ext-pdo": "*", - "ext-pdo_mysql": "*" + "ext-pdo_mysql": "*", + "ext-json": "*" }, "platform-dev": [] } diff --git a/controller/Controller.class.php b/controller/Controller.class.php index 290f4c9e..502c97fb 100644 --- a/controller/Controller.class.php +++ b/controller/Controller.class.php @@ -137,10 +137,11 @@ class Controller $router->get('/follow/{claim}', 'AcquisitionActions::executeFollowCampaign'); + $router->get('/i18n/get/{project}/{resource}/{language}.json', 'i18nActions::executeServeTranslationFile'); $router->get('/news/category/{category}', 'ContentActions::executePostCategoryFilter'); - $router->post('/set-culture', 'i18nActions::setCulture'); + $router->post('/i18n/set-culture', 'i18nActions::setCulture'); $permanentRedirectsPath = ROOT_DIR . '/data/redirect/permanent.yaml'; $tempRedirectsPath = ROOT_DIR . '/data/redirect/temporary.yaml'; diff --git a/controller/action/i18nActions.class.php b/controller/action/i18nActions.class.php index 0e9ae2ce..9526c9c9 100644 --- a/controller/action/i18nActions.class.php +++ b/controller/action/i18nActions.class.php @@ -22,4 +22,13 @@ class i18nActions extends Actions return Controller::redirect(Request::getReferrer()); } + + public static function executeServeTranslationFile(string $project, string $resource, string $language) + { + if (!Transifex::isConfigured()) { + throw new Exception('Please set Config::TRANSIFEX_API_KEY in your configuration.'); + } + + return View::renderJson(Transifex::getTranslationResourceFile($project, $resource, $language)); + } } diff --git a/data/config.php.example b/data/config.php.example index eec7cf99..b55471e7 100644 --- a/data/config.php.example +++ b/data/config.php.example @@ -12,4 +12,5 @@ $config = []; // $config[Config::MAILCHIMP_KEY] = ''; // $config[Config::AWS_LOG_ACCESS_KEY] = ''; // $config[Config::AWS_LOG_SECRET_KEY] = ''; +// $config[Config::TRANSIFEX_API_KEY] = ''; return $config; diff --git a/lib/thirdparty/Transifex.class.php b/lib/thirdparty/Transifex.class.php new file mode 100644 index 00000000..4d5393bf --- /dev/null +++ b/lib/thirdparty/Transifex.class.php @@ -0,0 +1,18 @@ + 'api:' . Config::get(Config::TRANSIFEX_API_KEY), + 'cache' => 1000 * 60 * 60 * 8 + ]), true); + } +} \ No newline at end of file diff --git a/lib/tools/Config.class.php b/lib/tools/Config.class.php index d00a367c..e55ebc05 100644 --- a/lib/tools/Config.class.php +++ b/lib/tools/Config.class.php @@ -15,6 +15,7 @@ class Config const GITHUB_PERSONAL_AUTH_TOKEN = 'github_personal_auth_token'; const LBRY_API_SERVER = "lbry_api_server"; const MAILCHIMP_KEY = "mailchimp_key"; + const TRANSIFEX_API_KEY = 'transifex_api_key'; const AWS_LOG_ACCESS_KEY = "aws_log_access_key"; const AWS_LOG_SECRET_KEY = "aws_log_secret_key"; const MAILGUN_API_KEY = "mailgun_api_key"; diff --git a/view/template/nav/_globalItems.php b/view/template/nav/_globalItems.php index f52d38fc..62ddb266 100644 --- a/view/template/nav/_globalItems.php +++ b/view/template/nav/_globalItems.php @@ -24,7 +24,7 @@ -