diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7656737..d10fe7d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -102,4 +102,5 @@ jobs: GITHUB_TOKEN=${{ github.token }} CROWDIN_TOKEN=${{ secrets.CROWDIN_TOKEN }} CROWDIN_PROJECT_ID=${{ secrets.CROWDIN_PROJECT_ID }} + CROWDIN_BASE_URL=https://spongepowered.crowdin.com BASE_URL=https://docs.spongepowered.org diff --git a/src/homepage/data/crowdin.js b/src/homepage/data/crowdin.js index e24b7a2..d09b7b9 100644 --- a/src/homepage/data/crowdin.js +++ b/src/homepage/data/crowdin.js @@ -3,6 +3,7 @@ const github = require('./github'); const crowdinProjectId = process.env.CROWDIN_PROJECT_ID; const crowdinToken = process.env.CROWDIN_TOKEN; +const crowdinBaseUrl = process.env.CROWDIN_BASE_URL || "https://crowdin.com"; const localLanguages = require('./languages'); @@ -13,7 +14,7 @@ const headers = { module.exports.getLocaleMappings = () => rp({ - uri: 'https://api.crowdin.com/api/v2/languages?limit=500', + uri: `${crowdinBaseUrl}/api/v2/languages?limit=500`, headers: { 'Accept': 'application/json' }, @@ -34,7 +35,7 @@ if (crowdinProjectId && crowdinToken) { getBranchMappings = () => new Promise((resolve, reject) => { let crowdinBranches = {}; rp({ - uri: `https://api.crowdin.com/api/v2/projects/${crowdinProjectId}/branches`, + uri: `${crowdinBaseUrl}/api/v2/projects/${crowdinProjectId}/branches`, headers: headers, json: true }).then((resp) => { @@ -53,7 +54,7 @@ if (crowdinProjectId && crowdinToken) { result[0].forEach(version => { promises.push(rp({ - uri: `https://api.crowdin.com/api/v2/projects/${crowdinProjectId}/branches/${result[1][version]}/languages/progress?limit=500`, + uri: `${crowdinBaseUrl}/api/v2/projects/${crowdinProjectId}/branches/${result[1][version]}/languages/progress?limit=500`, headers: headers, json: true }).then(resp => { diff --git a/src/theme/__init__.py b/src/theme/__init__.py index 9ccefe6..27a26db 100644 --- a/src/theme/__init__.py +++ b/src/theme/__init__.py @@ -1,4 +1,4 @@ -VERSION = (0, 6, 3) +VERSION = (1, 0, 0) __version__ = '.'.join(str(v) for v in VERSION) diff --git a/src/theme/languages.py b/src/theme/languages.py index 0871287..3c03a59 100644 --- a/src/theme/languages.py +++ b/src/theme/languages.py @@ -1,12 +1,12 @@ import json import os.path - import babel import requests from sphinx.util import logging from . import __version__ +CROWDIN_BASE_URL = os.getenv('CROWDIN_BASE_URL', 'https://crowdin.com') LOCAL_LANGUAGES_FILE = os.path.join(os.path.dirname(__file__), 'languages.json') LANGUAGES_FILE = 'build/languages.json' languages = None @@ -50,7 +50,7 @@ def load_languages(): languages = json.load(f) else: # Load Crowdin languages from API - r = requests.get('https://api.crowdin.com/api/v2/languages?limit=500') + r = requests.get('%s/api/v2/languages?limit=500' % CROWDIN_BASE_URL) r.raise_for_status() languages = {lang['data']['locale'].replace('-', '_'): { diff --git a/src/theme/scripts/list-translations b/src/theme/scripts/list-translations index 5f60f3b..a4269d2 100755 --- a/src/theme/scripts/list-translations +++ b/src/theme/scripts/list-translations @@ -6,6 +6,7 @@ import sys CROWDIN_PROJECT_ID = os.environ['CROWDIN_PROJECT_ID'] CROWDIN_TOKEN = os.environ['CROWDIN_TOKEN'] +CROWDIN_BASE_URL = os.environ['CROWDIN_BASE_URL'] BRANCH = sys.argv[1] @@ -15,14 +16,14 @@ headers = { } # Load language mappings -r = requests.get('https://api.crowdin.com/api/v2/languages?limit=500') +r = requests.get('%s/api/v2/languages?limit=500' % CROWDIN_BASE_URL) r.raise_for_status() # Map Crowdin codes to locale codes languages = {lang['data']['id']: lang['data']['locale'].replace('-', '_') for lang in r.json()['data']} branchId = None -r = requests.get('https://api.crowdin.com/api/v2/projects/%s/branches' % CROWDIN_PROJECT_ID, headers=headers) +r = requests.get('%s/api/v2/projects/%s/branches' % (CROWDIN_BASE_URL, CROWDIN_PROJECT_ID), headers=headers) r.raise_for_status() for language in r.json()['data']: if language['data']['name'] == BRANCH: @@ -30,8 +31,8 @@ for language in r.json()['data']: if not branchId: sys.exit(f"Could not find specified branch: ${branchId}!") -r = requests.get('https://api.crowdin.com/api/v2/projects/%s/branches/%s/languages/progress?limit=500' % - (CROWDIN_PROJECT_ID, branchId), headers=headers) +r = requests.get('%s/api/v2/projects/%s/branches/%s/languages/progress?limit=500' % + (CROWDIN_BASE_URL, CROWDIN_PROJECT_ID, branchId), headers=headers) r.raise_for_status() locales = [] diff --git a/src/theme/templates/layout.html b/src/theme/templates/layout.html index 5594dbe..ec1b742 100644 --- a/src/theme/templates/layout.html +++ b/src/theme/templates/layout.html @@ -30,10 +30,11 @@ {% block extrahead %} {% if language == 'translate' %} {# Include Crowdin In-Context Localization JS app if this is the translation build #} - - + {% endif %} {% endblock %}