-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e8626b9
commit e8bd712
Showing
15 changed files
with
37 additions
and
5,325 deletions.
There are no files selected for viewing
File renamed without changes
File renamed without changes
File renamed without changes
This file was deleted.
Oops, something went wrong.
Binary file not shown.
File renamed without changes
File renamed without changes
File renamed without changes
Binary file not shown.
This file was deleted.
Oops, something went wrong.
File renamed without changes
File renamed without changes
File renamed without changes
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,33 @@ | ||
import csv | ||
import glob | ||
import shutil | ||
import os | ||
import os.path | ||
|
||
days = {} | ||
DEFAULT_LANG = "fr" | ||
TARGET_DIRECTORY = "dist" | ||
os.mkdir(TARGET_DIRECTORY) | ||
|
||
with open("translations.csv") as csvfile: | ||
rows = csv.DictReader(csvfile, delimiter=',', quotechar='"') | ||
for row in rows: | ||
if row['day'] not in days: | ||
days[row['day']] = [] | ||
days[row['day']].append({k:v for k,v in row.items() if k != 'day'}) | ||
|
||
for day_id, day in days.items(): | ||
svg_filename_pattern = "j{day_id}_{lang}.svg" | ||
svg_filepath = os.path.join("day{day_id}".format(day_id), svg_filename_pattern.format(day_id=day_id, lang=DEFAULT_LANG)) | ||
print(svg_filepath) | ||
print(day) | ||
print() | ||
|
||
for lang in day: | ||
if lang != "fr": | ||
svg_translated_filepath = os.path.join(TARGET_DIRECTORY, svg_filename_pattern.format(day_id=day_id, lang=lang)) | ||
with open(svg_filepath, "r") as fin: | ||
with open(svg_translated_filepath, "w") as fout: | ||
for line in fin: | ||
for day_str in day: | ||
fout.write(line.replace(day_str[DEFAULT_LANG], day_str[lang])) |
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,4 @@ | ||
day,fr,es,it | ||
1,"Tous naissent comme des originaux,",l1, | ||
1,mais beaucoup meurent,l2, | ||
1,comme des photocopies,l3, |