source translation files from lbry.com

This commit is contained in:
Jeremy Kauffman 2019-09-05 17:31:29 -04:00
parent 3f90ea07b4
commit f40ce4a86c
8 changed files with 52 additions and 20 deletions

View file

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

37
composer.lock generated
View file

@ -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": []
}

View file

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

View file

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

View file

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

18
lib/thirdparty/Transifex.class.php vendored Normal file
View file

@ -0,0 +1,18 @@
<?php
class Transifex
{
public static function isConfigured() {
return (boolean)Config::get(Config::TRANSIFEX_API_KEY);
}
public static function getTranslationResourceFile($project, $resource, $language)
{
$url = "https://www.transifex.com/api/2/project/$project/resource/$resource/translation/$language?file=1";
return json_decode(CurlWithCache::get($url, [], [
'password' => 'api:' . Config::get(Config::TRANSIFEX_API_KEY),
'cache' => 1000 * 60 * 60 * 8
]), true);
}
}

View file

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

View file

@ -24,7 +24,7 @@
</div>
<?php /*
<div class="control-item no-label-desktop">
<form action="/set-culture" method="POST">
<form action="/i18n/set-culture" method="POST">
<select id="language-dropdown" name="culture">
<?php foreach ($cultures as $culture): ?>
<option value="<?php echo $culture ?>" <?php echo $culture == $selectedCulture ? 'selected="selected"' : '' ?>>