Skip to content

Commit 7d5e26d

Browse files
Merge pull request #629 from nextcloud/app_api_python_l10n_support
feat(translationtool): add Python support for translations
2 parents c544960 + 4ba729c commit 7d5e26d

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

translations-app/handleAppTranslations.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ if [ ! -f '/app/.tx/config' ]; then
1717
fi
1818

1919
APP_ID=$(grep -oE '<id>.*</id>' appinfo/info.xml | head --lines 1 | sed -E 's/<id>(.*)<\/id>/\1/')
20+
IS_EX_APP=$(grep -q '<external-app>' appinfo/info.xml && grep -q '</external-app>' appinfo/info.xml && echo "true" || echo "false")
2021
RESOURCE_ID=$(grep -oE '\[o:nextcloud:p:nextcloud:r:.*\]' .tx/config | sed -E 's/\[o:nextcloud:p:nextcloud:r:(.*)\]/\1/')
2122
SOURCE_FILE=$(grep -oE '^source_file\s*=\s*(.+)$' .tx/config | sed -E 's/source_file\s*=\s*(.+)/\1/')
2223

@@ -136,6 +137,12 @@ do
136137

137138
# create git commit and push it
138139
git add l10n/*.js l10n/*.json
140+
141+
# for ExApps, we need to include .po,.mo translation files as well
142+
if [ "$IS_EX_APP" = "true" ]; then
143+
git add translationfiles/*.po translationfiles/*.mo
144+
fi
145+
139146
git commit -am "fix(l10n): Update translations from Transifex" -s || true
140147
git push origin $version
141148

translations/translationtool/src/translationtool.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function createOrCheckPotFile(bool $checkFiles = false): void {
5555
$this->createFakeFileForVueFiles();
5656
$this->createFakeFileForLocale();
5757
$translatableFiles = $this->findTranslatableFiles(
58-
['.php', '.js', '.jsx', '.mjs', '.html', '.ts', '.tsx'],
58+
['.php', '.js', '.jsx', '.mjs', '.html', '.ts', '.tsx', '.py'],
5959
['.min.js']
6060
);
6161

@@ -67,13 +67,17 @@ public function createOrCheckPotFile(bool $checkFiles = false): void {
6767
$keywords = '';
6868
if (substr($entry, -4) === '.php') {
6969
$keywords = '--keyword=t --keyword=n:1,2';
70+
} elseif (substr($entry, -3) === '.py') {
71+
$keywords = '--keyword=_ --keyword=_n:1,2';
7072
} else {
7173
$keywords = '--keyword=t:2 --keyword=n:2,3';
7274
}
7375

7476
$language = '--language=';
7577
if (substr($entry, -4) === '.php') {
7678
$language .= 'PHP';
79+
} elseif (substr($entry, -3) === '.py') {
80+
$language .= 'Python';
7781
} else {
7882
$language .= 'Javascript';
7983
}
1.4 KB
Binary file not shown.

0 commit comments

Comments
 (0)