forked from Azure/azure-cli
-
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.
Adds tool to extract strings Allows config file to specify locale
- Loading branch information
Showing
8 changed files
with
145 additions
and
88 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,6 @@ env/ | |
.ptvs/ | ||
|
||
# Build results | ||
bin/ | ||
obj/ | ||
dist/ | ||
MANIFEST | ||
|
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,30 @@ | ||
#! /usr/bin/env python3 | ||
|
||
import os | ||
import re | ||
import subprocess | ||
import sys | ||
|
||
from pathlib import Path | ||
|
||
ROOT = Path(__file__).resolve().parent.parent / "src" / "azure" / "cli" | ||
OUTPUT = ROOT / "locale" / "en-US" / "messages.txt" | ||
|
||
print('Extracting from:', ROOT) | ||
|
||
if not ROOT.is_dir(): | ||
print("Failed to locate 'azure/cli'") | ||
sys.exit(1) | ||
|
||
if not OUTPUT.parent.is_dir(): | ||
os.makedirs(str(OUTPUT.parent)) | ||
|
||
with open(str(OUTPUT), 'w', encoding='utf-8-sig') as f_out: | ||
for path in ROOT.rglob('*.py'): | ||
with open(str(path), 'r', encoding='utf-8') as f: | ||
content = f.read() | ||
for m in re.finditer('[^\w_]_\(("(.+)"|\'(.+)\')\)', content): | ||
print('# From', path, ':', m.span()[0], file=f_out) | ||
print('KEY:', m.group(2) or m.group(3), file=f_out) | ||
print(m.group(2) or m.group(3), file=f_out) | ||
print(file=f_out) |
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,30 @@ | ||
import os.path | ||
|
||
from codecs import open | ||
|
||
def install(locale_dir): | ||
mapping = [] | ||
|
||
with open(os.path.join(locale_dir, "messages.txt"), 'r', encoding='utf-8-sig') as f: | ||
for i in f: | ||
if not i or i.startswith('#') or not i.strip(): | ||
continue | ||
if i.startswith('KEY: '): | ||
mapping.append((i[5:].strip(), None)) | ||
else: | ||
mapping[-1] = (mapping[-1][0], i.strip()) | ||
|
||
translations = dict(mapping) | ||
def _(key): | ||
return translations.get(key) or '<NO_TRANSLATION:{}>'.format(key) | ||
_.locale_dir = locale_dir | ||
|
||
__builtins__['_'] = _ | ||
|
||
def get_file(name): | ||
try: | ||
src = _.locale_dir | ||
except (NameError, AttributeError): | ||
raise RuntimeError("localizations not installed") | ||
|
||
return os.path.join(src, name) |
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,60 @@ | ||
# From D:\Repos\azure-cli\src\azure\cli\_argparse.py : 1208 | ||
KEY: Argument {0} is required | ||
Argument {0} is required | ||
|
||
# From D:\Repos\azure-cli\src\azure\cli\_argparse.py : 6848 | ||
KEY: argument '{0}' does not take a value | ||
argument '{0}' does not take a value | ||
|
||
# From D:\Repos\azure-cli\src\azure\cli\commands\login.py : 1147 | ||
KEY: user password or service principal secret, will prompt if not given. | ||
user password or service principal secret, will prompt if not given. | ||
|
||
# From D:\Repos\azure-cli\src\azure\cli\commands\login.py : 1253 | ||
KEY: If given, log in as a service principal rather than a user. | ||
If given, log in as a service principal rather than a user. | ||
|
||
# From D:\Repos\azure-cli\src\azure\cli\commands\login.py : 1367 | ||
KEY: A PEM encoded certificate private key file. | ||
A PEM encoded certificate private key file. | ||
|
||
# From D:\Repos\azure-cli\src\azure\cli\commands\login.py : 1454 | ||
KEY: A hex encoded thumbprint of the certificate. | ||
A hex encoded thumbprint of the certificate. | ||
|
||
# From D:\Repos\azure-cli\src\azure\cli\commands\login.py : 1535 | ||
KEY: Tenant domain or ID to log into. | ||
Tenant domain or ID to log into. | ||
|
||
# From D:\Repos\azure-cli\src\azure\cli\commands\login.py : 1597 | ||
KEY: do not prompt for confirmation of PII storage. | ||
do not prompt for confirmation of PII storage. | ||
|
||
# From D:\Repos\azure-cli\src\azure\cli\commands\login.py : 1927 | ||
KEY: Unknown environment {0} | ||
Unknown environment {0} | ||
|
||
# From D:\Repos\azure-cli\src\azure\cli\commands\login.py : 2091 | ||
KEY: Tenant: | ||
Tenant: | ||
|
||
# From D:\Repos\azure-cli\src\azure\cli\commands\login.py : 2381 | ||
KEY: Password: | ||
Password: | ||
|
||
# From D:\Repos\azure-cli\src\azure\cli\commands\login.py : 2883 | ||
KEY: No subscriptions found for this account | ||
No subscriptions found for this account | ||
|
||
# From D:\Repos\azure-cli\src\azure\cli\commands\login.py : 2991 | ||
KEY: Setting subscription %s as default | ||
Setting subscription %s as default | ||
|
||
# From D:\Repos\azure-cli\src\azure\cli\commands\storage.py : 268 | ||
KEY: the resource group name | ||
the resource group name | ||
|
||
# From D:\Repos\azure-cli\src\azure\cli\commands\storage.py : 332 | ||
KEY: the subscription id | ||
the subscription id | ||
|
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