-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The PO folder must contain one sub-folder for each language, each sub-folder contains PO files in that language.
- Loading branch information
Showing
3 changed files
with
35 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# SPDX-FileCopyrightText: 2023 Phu Hung Nguyen <[email protected]> | ||
# SPDX-License-Identifier: LGPL-2.1-or-later | ||
|
||
import logging | ||
import os | ||
import subprocess | ||
|
||
|
||
def compile_po(args): | ||
""" | ||
Compile translated messages to binary format stored in 'locale/{lang}/LC_MESSAGES' directory | ||
:param args: arguments passed in command line, containing | ||
- dir: path of the directory containing subdirectories with PO files inside, in the form of {lang}/*.po | ||
:return: None | ||
""" | ||
po_dir = args.dir | ||
for lang in os.listdir(po_dir): | ||
target_path = f'locale/{lang}/LC_MESSAGES' | ||
os.makedirs(target_path, exist_ok=True) | ||
src_path = f'{po_dir}/{lang}' | ||
|
||
for po in os.listdir(src_path): | ||
po_path = f'{src_path}/{po}' | ||
mo_path = f'{target_path}/{po[:-2]}mo' | ||
command = f'msgfmt {po_path} -o {mo_path}' | ||
subprocess.run(command, shell=True, check=True) | ||
logging.info(f'Compiled {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 |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
|
||
[tool.poetry] | ||
name = "hugo-gettext" | ||
version = "0.2.0" | ||
version = "0.3.0" | ||
description = "I18n with gettext for Hugo" | ||
authors = ["Phu Hung Nguyen <[email protected]>"] | ||
license = "GPL-3.0-or-later" | ||
|