Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ENH] Adding translations infrastructure and a word translation (#71)
* Adding translations infrastructure and a word translation This is a copy from [sphinx-book-theme](https://github.com/executablebooks/sphinx-book-theme/tree/master/sphinx_book_theme/translations). * Get the translation on the nodes Signed-off-by: Vincent-Xavier JUMEL <vincent-xavier.jumel@ac-paris.fr> * Update nodes.py * Delete theorem.json * Added some translations and remove old catalog Signed-off-by: Vincent-Xavier JUMEL <vincent-xavier.jumel@ac-paris.fr> * Adding french translation Signed-off-by: Vincent-Xavier JUMEL <endymion@thetys-retz.net> * Adding French translation only Signed-off-by: Vincent-Xavier JUMEL <endymion@thetys-retz.net> * Adding endline Signed-off-by: Vincent-Xavier JUMEL <endymion@thetys-retz.net> * Forgot the generated po files Signed-off-by: Vincent-Xavier JUMEL <endymion@thetys-retz.net> Co-authored-by: Vincent-Xavier JUMEL <vincent-xavier.jumel@ac-paris.fr>
- Loading branch information
1 parent
75b4e15
commit e400bd9
Showing
28 changed files
with
91 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
*.po | ||
!*.mo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
JSONs created using https://smodin.me/translate-one-text-into-multiple-languages | ||
|
||
To convert to locale files run `python sphinx_proof/translations/_convert.py` |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import json | ||
import os | ||
from pathlib import Path | ||
import subprocess | ||
|
||
|
||
def convert_json(folder=None): | ||
folder = folder or Path(__file__).parent | ||
|
||
# remove exising | ||
for path in (folder / "locales").glob("**/proof.po"): | ||
path.unlink() | ||
|
||
# compile po | ||
for path in (folder / "jsons").glob("*.json"): | ||
data = json.loads(path.read_text("utf8")) | ||
assert data[0]["symbol"] == "en" | ||
english = data[0]["text"] | ||
for item in data[1:]: | ||
language = item["symbol"] | ||
out_path = folder / "locales" / language / "LC_MESSAGES" / "proof.po" | ||
if not out_path.parent.exists(): | ||
out_path.parent.mkdir(parents=True) | ||
if not out_path.exists(): | ||
header = f""" | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Sphinx-Proof\\n" | ||
"MIME-Version: 1.0\\n" | ||
"Content-Type: text/plain; charset=UTF-8\\n" | ||
"Content-Transfer-Encoding: 8bit\\n" | ||
"Language: {language}\\n" | ||
"Plural-Forms: nplurals=2; plural=(n != 1);\\n" | ||
""" | ||
out_path.write_text(header) | ||
|
||
with out_path.open("a") as f: | ||
f.write("\n") | ||
f.write(f'msgid "{english}"\n') | ||
text = item["text"].replace('"', '\\"') | ||
f.write(f'msgstr "{text}"\n') | ||
|
||
# compile mo | ||
for path in (folder / "locales").glob("**/proof.po"): | ||
print(path) | ||
subprocess.check_call( | ||
[ | ||
"msgfmt", | ||
os.path.abspath(path), | ||
"-o", | ||
os.path.abspath(path.parent / "proof.mo"), | ||
] | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
convert_json() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[{"language":"English","symbol":"en","text":"Algorithm"},{"language":"French","symbol":"fr","text":"Algorithme"}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[{"language":"English","symbol":"en","text":"Axiom"},{"language":"French","symbol":"fr","text":"Axiome"}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[{"language":"English","symbol":"en","text":"Conjecture"},{"language":"Arabic","symbol":"ar","text":"تخمين"},{"language":"Dutch","symbol":"nl","text":"Vermoeden"},{"language":"French","symbol":"fr","text":"Conjecture"},{"language":"German","symbol":"de","text":"Vermutung"},{"language":"Italian","symbol":"it","text":"Congetturare"},{"language":"Japanese","symbol":"ja","text":"推測"},{"language":"Russian","symbol":"ru","text":"Гипотеза"},{"language":"Spanish","symbol":"es","text":"Conjetura"}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[{"language":"English","symbol":"en","text":"Criterion"},{"language":"French","symbol":"fr","text":"Critère"}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[{"language":"English","symbol":"en","text":"Definition"},{"language":"Arabic","symbol":"ar","text":"تعريف"},{"language":"Dutch","symbol":"nl","text":"Definitie"},{"language":"French","symbol":"fr","text":"Définition"},{"language":"German","symbol":"de","text":"Definition"},{"language":"Italian","symbol":"it","text":"Definizione"},{"language":"Japanese","symbol":"ja","text":"意味"},{"language":"Russian","symbol":"ru","text":"Определение"},{"language":"Spanish","symbol":"es","text":"Definición"}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[{"language":"English","symbol":"en","text":"Example"},{"language":"French","symbol":"fr","text":"Exemple"}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[{"language":"English","symbol":"en","text":"Lemma"},{"language":"Arabic","symbol":"ar","text":"ليما"},{"language":"Dutch","symbol":"nl","text":"Lemma"},{"language":"French","symbol":"fr","text":"Lemme"},{"language":"German","symbol":"de","text":"Lemma"},{"language":"Italian","symbol":"it","text":"Lemma"},{"language":"Japanese","symbol":"ja","text":"補題"},{"language":"Russian","symbol":"ru","text":"Лемма"},{"language":"Spanish","symbol":"es","text":"Lema"}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[{"language":"English","symbol":"en","text":"Observation"},{"language":"French","symbol":"fr","text":"Observation"}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[{"language":"English","symbol":"en","text":"Property"},{"language":"French","symbol":"fr","text":"Propriété"}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[{"language":"English","symbol":"en","text":"Proposition"},{"language":"French","symbol":"fr","text":"Proposition"}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[{"language":"English","symbol":"en","text":"Remark"},{"language":"Arabic","symbol":"ar","text":"ملاحظة"},{"language":"Dutch","symbol":"nl","text":"Opmerking"},{"language":"French","symbol":"fr","text":"Remarque"},{"language":"German","symbol":"de","text":"Anmerkung"},{"language":"Italian","symbol":"it","text":"osservazione"},{"language":"Japanese","symbol":"ja","text":"述べる"},{"language":"Russian","symbol":"ru","text":"Замечание"},{"language":"Spanish","symbol":"es","text":"Observación"}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[{"language":"English","symbol":"en","text":"Theorem"},{"language":"Arabic","symbol":"ar","text":"نظرية"},{"language":"Dutch","symbol":"nl","text":"Stelling"},{"language":"French","symbol":"fr","text":"Théorème"},{"language":"German","symbol":"de","text":"Satz"},{"language":"Italian","symbol":"it","text":"Teorema"},{"language":"Japanese","symbol":"ja","text":"定理"},{"language":"Russian","symbol":"ru","text":"Теорема"},{"language":"Spanish","symbol":"es","text":"Teorema"}] |
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.