[chrome-gnome-shell] i18n: workaround for pt language code.



commit e92a877df20952fe9e0e809a956f8b64cf799168
Author: Yuri Konotopov <ykonotopov gmail com>
Date:   Thu Aug 4 18:33:47 2016 +0300

    i18n: workaround for pt language code.
    
    In Chrome "pt_PT" language code is used for Portuguese (Portugal).

 contrib/chrome-messages2po.py |   11 +++++++----
 contrib/po2chrome-messages.py |   11 +++++++----
 2 files changed, 14 insertions(+), 8 deletions(-)
---
diff --git a/contrib/chrome-messages2po.py b/contrib/chrome-messages2po.py
index 824fe05..05ae355 100755
--- a/contrib/chrome-messages2po.py
+++ b/contrib/chrome-messages2po.py
@@ -138,11 +138,14 @@ def run():
        with open(os.path.join(args.po, 'LINGUAS'), 'r') as file:
                for line in file:
                        lang = line.strip()
+                       chromeLang = lang
+                       if lang == 'pt':
+                               chromeLang = 'pt_PT'
 
-                       if not lang or not os.path.isfile(os.path.join(args.locales, lang, 'messages.json')):
+                       if not lang or not os.path.isfile(os.path.join(args.locales, chromeLang, 
'messages.json')):
                                continue
 
-                       with open(os.path.join(args.locales, lang, "messages.json"), 'r') as file:
+                       with open(os.path.join(args.locales, chromeLang, "messages.json"), 'r') as file:
                                chromeMessages = json.load(file)
 
                        po_path = os.path.join(args.po, lang + '.po')
@@ -162,8 +165,8 @@ def run():
                                                messageKey = occurrence[len(METADATA_SUFFIX):]
                                                break
                                        elif occurrence == METADATA_STORE_DESCRIPTION:
-                                               if os.path.isfile(os.path.join(args.chrome_store_description, 
lang)):
-                                                       with open(os.path.join(args.chrome_store_description, 
lang)) as file:
+                                               if os.path.isfile(os.path.join(args.chrome_store_description, 
chromeLang)):
+                                                       with open(os.path.join(args.chrome_store_description, 
chromeLang)) as file:
                                                                entry.msgstr = file.read()
                                                                break
 
diff --git a/contrib/po2chrome-messages.py b/contrib/po2chrome-messages.py
index eb34ef3..bbae053 100755
--- a/contrib/po2chrome-messages.py
+++ b/contrib/po2chrome-messages.py
@@ -71,6 +71,9 @@ def run():
        with open(os.path.join(args.po, 'LINGUAS'), 'r') as file:
                for line in file:
                        lang = line.strip()
+                       chromeLang = lang
+                       if lang == 'pt':
+                               chromeLang = 'pt_PT'
 
                        po_path = os.path.join(args.po, lang + '.po')
 
@@ -92,18 +95,18 @@ def run():
 
                                messages[messageKey] = messageEntry
 
-                       os.makedirs(os.path.join(args.locales, lang), exist_ok=True)
-                       with open(os.path.join(args.locales, lang, "messages.json"), 'w') as file:
+                       os.makedirs(os.path.join(args.locales, chromeLang), exist_ok=True)
+                       with open(os.path.join(args.locales, chromeLang, "messages.json"), 'w') as file:
                                json.dump(messages, file, indent='\t', sort_keys=True)
                                file.write('\n')
 
                        entry = find_chrome_entry(po, METADATA_STORE_DESCRIPTION, exact=True)
                        if entry and entry.msgstr and not 'fuzzy' in entry.flags:
-                               with open(os.path.join(args.chrome_store_description, lang), 'w') as file:
+                               with open(os.path.join(args.chrome_store_description, chromeLang), 'w') as 
file:
                                        file.write(entry.msgstr)
                        else:
                                try:
-                                       os.remove(os.path.join(args.chrome_store_description, lang))
+                                       os.remove(os.path.join(args.chrome_store_description, chromeLang))
                                except FileNotFoundError:
                                        pass
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]