aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorsecondl1ght <[email protected]>2022-08-22 18:00:08 -0400
committersecondl1ght <[email protected]>2022-08-22 18:00:08 -0400
commit1b802b478f187a9ab61bb455df0c3863595e906a (patch)
treeecc8f9b0547bf53e9035cc37c76c85e558565c15 /src
parent2aa7156e12200798c45a53878dbcc37c77625752 (diff)
parentc80b37679f80a0d3947d3350ca793faca8f3aa31 (diff)
downloadcoinos-ui-1b802b478f187a9ab61bb455df0c3863595e906a.tar.gz
coinos-ui-1b802b478f187a9ab61bb455df0c3863595e906a.zip
Merge branch 'master' of github.com:coinos/coinos-ui-v2
Diffstat (limited to 'src')
-rw-r--r--src/components/About.svelte2
-rw-r--r--src/locales/en.json16
-rw-r--r--src/locales/guided_translation.py91
3 files changed, 100 insertions, 9 deletions
diff --git a/src/components/About.svelte b/src/components/About.svelte
index 817d9026..db74fd96 100644
--- a/src/components/About.svelte
+++ b/src/components/About.svelte
@@ -57,7 +57,7 @@
<ul
class="w-full mx-auto md:w-[700px] lg:w-[500px] xl:w-auto text-secondary px-1 md:px-10 text-xl list-disc space-y-5"
>
- {#each $json('about.founder.qualifications') as qualification}
+ {#each Object.values($json('about.founder.qualifications')) as qualification}
<li>{qualification}</li>
{/each}
</ul>
diff --git a/src/locales/en.json b/src/locales/en.json
index e4fb9f39..1d3446c9 100644
--- a/src/locales/en.json
+++ b/src/locales/en.json
@@ -14,14 +14,14 @@
"header": "The Founder",
"name": "Adam Soltys",
"position": "Chief Technical Officer",
- "qualifications": [
- "Running bitcoin since 2011",
- "20+ years web development experience in government and industry",
- "Early bitcoin Vancouver meetup organizer",
- "Founder of The bitcoin Co-op and early supporter of Decentral Vancouver",
- "Yogi, permaculturist, anarchist, decentralist",
- "Husband, father, brother, son"
- ]
+ "qualifications": {
+ "bitcoin": "Running bitcoin since 2011",
+ "webDev": "20+ years web development experience in government and industry",
+ "bitcoinVancouver": "Early bitcoin Vancouver meetup organizer",
+ "bitcoinCoop": "Founder of The bitcoin Co-op and early supporter of Decentral Vancouver",
+ "beliefs": "Yogi, permaculturist, anarchist, decentralist",
+ "familialRelationships": "Husband, father, brother, son"
+ }
},
"locations": {
"header": "Locations",
diff --git a/src/locales/guided_translation.py b/src/locales/guided_translation.py
new file mode 100644
index 00000000..e5f94cfe
--- /dev/null
+++ b/src/locales/guided_translation.py
@@ -0,0 +1,91 @@
+#!/usr/bin/python
+
+import argparse, json, logging
+
+DEFAULT_FROM_LOCALE = 'en'
+
+def nested_dict_keys(d, _keyname_prefix=''):
+ entry_list = []
+ for key in d:
+ value = d[key]
+ if isinstance(value, dict):
+ entry_list += nested_dict_keys(value, _keyname_prefix + key + '.')
+ else:
+ entry_list += [_keyname_prefix + key]
+ return entry_list
+
+def localize_string(string_id, from_data, to_data):
+ logging.debug("Translating string with id %s", string_id)
+ id_parts = string_id.split('.')
+
+ # get original string
+ to_translate = from_data
+ for id_part in id_parts:
+ to_translate = to_translate[id_part]
+
+ # get translated string
+ print("Please translate the following text (id " + string_id + "):")
+ print(to_translate)
+
+ translated = input("Type the translated text then press ENTER: ")
+
+ # find/create place to put translated string
+ translation_location = to_data # the dictionary or list that should contain the translated string
+ for id_part in id_parts[:-1]:
+ if id_part not in translation_location:
+ translation_location[id_part] = {}
+ translation_location = translation_location[id_part]
+
+ translation_location[id_parts[-1]] = translated
+
+if __name__ == "__main__":
+ # setup and parse commandline arguments
+ args_parser = argparse.ArgumentParser(description="guided translation of CoinOS")
+ args_parser.add_argument('from_locale', nargs='?', type=str,
+ help='which locale to translate from')
+ args_parser.add_argument('to_locale', nargs='?', type=str,
+ help='which locale to translate to')
+ args = args_parser.parse_args()
+
+ from_locale = args.from_locale or input("Which locale do you want to translate from (default: %s)? "
+ % DEFAULT_FROM_LOCALE) or DEFAULT_FROM_LOCALE
+ to_locale = args.to_locale or input("Which locale do you want to translate to? ")
+ if not to_locale:
+ raise ValueError("You need to specify a language to translate to.")
+
+ logging.basicConfig(format='%(levelname)s: %(message)s')
+
+ # load locale files
+ logging.debug("Reading file to convert from (%s.json)", from_locale)
+ with open(from_locale + ".json", 'r') as from_file:
+ from_json_text = from_file.read()
+ logging.debug("Converting from data from JSON to object")
+ from_data = json.loads(from_json_text)
+ from_id_list = nested_dict_keys(from_data)
+ logging.info("Successfully obtained %d strings from locale %s",
+ len(from_id_list), from_locale)
+ logging.debug("List of strings: %s", from_id_list)
+
+ logging.debug("Reading file to convert to (%s.json)", to_locale)
+ with open(to_locale + ".json", 'r') as to_file:
+ to_json_text = to_file.read()
+ logging.debug("Converting to data from JSON to object")
+ to_data = json.loads(to_json_text)
+ to_id_list = nested_dict_keys(to_data)
+ logging.info("Successfully obtained %d strings from locale %s",
+ len(to_id_list), to_locale)
+ logging.debug("List of strings: %s", to_id_list)
+
+ # localize strings!
+ try:
+ for string_id in from_id_list:
+ if string_id not in to_id_list:
+ localize_string(string_id, from_data, to_data)
+ to_id_list.append(string_id)
+ except KeyboardInterrupt:
+ print("Program interrupted. Saving strings and closing program...")
+
+ # save localized data
+ with open(to_locale + ".json", 'w') as to_file:
+ json.dump(to_data, to_file, ensure_ascii=False, indent=2)
+ logging.info("Saved %d localized strings to %s.json", len(to_id_list), to_locale)
inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; } td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } .highlight .hll { background-color: #ffffcc } .highlight .c { color: #888 } /* Comment */ .highlight .err { color: #A61717; background-color: #E3D2D2 } /* Error */ .highlight .k { color: #080; font-weight: bold } /* Keyword */ .highlight .ch { color: #888 } /* Comment.Hashbang */ .highlight .cm { color: #888 } /* Comment.Multiline */ .highlight .cp { color: #C00; font-weight: bold } /* Comment.Preproc */ .highlight .cpf { color: #888 } /* Comment.PreprocFile */ .highlight .c1 { color: #888 } /* Comment.Single */ .highlight .cs { color: #C00; font-weight: bold; background-color: #FFF0F0 } /* Comment.Special */ .highlight .gd { color: #000; background-color: #FDD } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */ .highlight .gr { color: #A00 } /* Generic.Error */ .highlight .gh { color: #333 } /* Generic.Heading */ .highlight .gi { color: #000; background-color: #DFD } /* Generic.Inserted */ .highlight .go { color: #888 } /* Generic.Output */ .highlight .gp { color: #555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666 } /* Generic.Subheading */ .highlight .gt { color: #A00 } /* Generic.Traceback */ .highlight .kc { color: #080; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #080; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #080; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #080 } /* Keyword.Pseudo */ .highlight .kr { color: #080; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #00D; font-weight: bold } /* Literal.Number */ .highlight .s { color: #D20; background-color: #FFF0F0 } /* Literal.String */ .highlight .na { color: #369 } /* Name.Attribute */ .highlight .nb { color: #038 } /* Name.Builtin */ .highlight .nc { color: #B06; font-weight: bold } /* Name.Class */ .highlight .no { color: #036; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555 } /* Name.Decorator */ .highlight .ne { color: #B06; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #06B; font-weight: bold } /* Name.Function */ .highlight .nl { color: #369; font-style: italic } /* Name.Label */ .highlight .nn { color: #B06; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #369; font-weight: bold } /* Name.Property */ .highlight .nt { color: #B06; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #369 } /* Name.Variable */ .highlight .ow { color: #080 } /* Operator.Word */ .highlight .w { color: #BBB } /* Text.Whitespace */ .highlight .mb { color: #00D; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #00D; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #00D; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #00D; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #00D; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #D20; background-color: #FFF0F0 } /* Literal.String.Affix */ .highlight .sb { color: #D20; background-color: #FFF0F0 } /* Literal.String.Backtick */ .highlight .sc { color: #D20; background-color: #FFF0F0 } /* Literal.String.Char */ .highlight .dl { color: #D20; background-color: #FFF0F0 } /* Literal.String.Delimiter */ .highlight .sd { color: #D20; background-color: #FFF0F0 } /* Literal.String.Doc */ .highlight .s2 { color: #D20; background-color: #FFF0F0 } /* Literal.String.Double */ .highlight .se { color: #04D; background-color: #FFF0F0 } /* Literal.String.Escape */ .highlight .sh { color: #D20; background-color: #FFF0F0 } /* Literal.String.Heredoc */ .highlight .si { color: #33B; background-color: #FFF0F0 } /* Literal.String.Interpol */ .highlight .sx { color: #2B2; background-color: #F0FFF0 } /* Literal.String.Other */ .highlight .sr { color: #080; background-color: #FFF0FF } /* Literal.String.Regex */ .highlight .s1 { color: #D20; background-color: #FFF0F0 } /* Literal.String.Single */ .highlight .ss { color: #A60; background-color: #FFF0F0 } /* Literal.String.Symbol */ .highlight .bp { color: #038 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #06B; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #369 } /* Name.Variable.Class */ .highlight .vg { color: #D70 } /* Name.Variable.Global */ .highlight .vi { color: #33B } /* Name.Variable.Instance */ .highlight .vm { color: #369 } /* Name.Variable.Magic */ .highlight .il { color: #00D; font-weight: bold } /* Literal.Number.Integer.Long */
@import "bootstrap.min.css";
@import "bootstrap-responsive.min.css";
@import "font-awesome.css";

.hero-unit {
  background: url(/img/vancouver.jpg);
  background-size: 100% 100%;
}

.hero-unit p {
  background: rgba(255, 255, 255, 0.5);
}

.navbar-inverse, .navbar-inverse .navbar-link, .navbar-inverse .brand, .navbar-inverse .nav > li > a { color: #eee; }

footer { 
  background: black; 
  color: #ddd; 
  padding: 10px 0px 2px 5px; 
  margin: 0;
  text-align: right;
}

#ask, #bid { color: white; }
div.directory { width: 500px; float: left;  border: 1px dashed #ccc; padding: 10px; margin: 10px; }
div.directory img { height: 180px; float: left; padding-right: 10px; }
div.directory p { font-size: 13px; }
div.directory h2 a { text-decoration: none; color: #000; }
div.row-fluid td.first { text-align: right; }