Skip to content

Commit

Permalink
if NOT USED in comment, hash locale will use ? as prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
xabk committed Mar 30, 2023
1 parent f3930d4 commit a07adbd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 3 additions & 1 deletion base.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ script-parameters:

loc_targets: ['Game']

hash_locale: ia-001 # Set to '' (empty) to disable hash locale generation
hash_locale: ia-001 # Set to '' (empty) to disable hash locale generation\
hash_locale: en-SG # Set to '' (empty) to disable hash locale generation
hash_not_used_marker: 'NOT USED' # If this is in comment, use not_used_prefix
hash_prefix: '# '
hash_suffix: ' ~'

Expand Down
7 changes: 7 additions & 0 deletions test-lang.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class ProcessTestAndHashLocales(LocTask):
hash_locale: str = 'ia-001'

# Hash locale parameters
hash_not_used_marker: str = 'NOT USED' # If this is in comment, use not_used_prefix
hash_prefix_not_used: str = '? ' # Prefix for strings with `not_used` in comment
hash_prefix: str = '# ' # Prefix for each string in hash locale
hash_suffix: str = ' ~' # Suffix for each string in hash locale

Expand Down Expand Up @@ -332,6 +334,11 @@ def process_hash_locale(self, po_file: str):
logger.info(f'Opened hash locale file: {po_file}')

for entry in po:
prefix = (
self.hash_prefix_not_used
if self.hash_not_used_marker in entry.comment
else self.hash_prefix
)
entry.msgstr = self.hash_prefix + entry.msgid + self.hash_suffix

po.save(po_file)
Expand Down

0 comments on commit a07adbd

Please sign in to comment.