Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: cms/bin/xtm_translations/constants.py

Issue 29886648: Issue #6942 - Add XTM integration in CMS (Closed)
Patch Set: Created Sept. 20, 2018, 4:24 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 # This file is part of the Adblock Plus web scripts,
2 # Copyright (C) 2006-present eyeo GmbH
3 #
4 # Adblock Plus is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License version 3 as
6 # published by the Free Software Foundation.
7 #
8 # Adblock Plus is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
15 """Messages and other constants used by the translation script."""
Vasily Kuznetsov 2018/09/24 16:32:11 Nit: The docstring is more noticeable if you leave
Tudor Avram 2018/09/25 12:26:24 Done.
16
17
18 def input_fn(text):
Vasily Kuznetsov 2018/09/24 16:32:11 Could this be a better fit in `utils.py`?
Tudor Avram 2018/09/25 12:26:24 Done.
19 try:
20 return raw_input(text)
21 except Exception:
22 return input(text)
23
24
25 class InfoMessages:
26 PROJECT_NAME_CREATING = "Creating new project: '{0}'."
27 PROJECT_CREATED = "Project created! The project ID is: '{0}'."
28 GENERATING_TOKEN = "Generating token for '{0}' (userID: {1})."
29 TOKEN_GENERATED = 'Token generated!: {}'
30 TOKEN_SAVE_TO_ENV_VAR = ('To utilize the token, please copy-paste and '
31 'run the following command in your shell: '
32 '\n\n\t{}\n\n')
33 NO_FILES_FOUND = 'No target files were found for project {}!'
34 FILES_DOWNLOADED = 'Files downloaded! Now saving them to disc.'
35 FILES_SAVED = 'Files successfully saved in {}!'
36 EXTRACTING_STRINGS = 'Extracting page strings. This might take a while...'
37 RESOLVING_LOCALES = 'Resolving locales...'
38 ADDING_LANGUAGES = 'Adding the following languages to project {0}: {1}'
39 UPLOADING_FILES = 'Uploading {0} files to the project! Please be patient.'
40 CREATED_JOB = 'Created job {0} for {1}, with target language: {2}.'
41 SAVED_PROJECT_ID = 'The project id was saved to settings.ini!'
42 NO_JOBS_CREATED = 'No jobs were created for the current project!'
43 FILES_UPLOADED = 'The files were successfully uploaded to XTM Cloud!'
44 WAITING_FOR_PROJECT = ('Waiting for the project processing to finish. '
45 'This might take a while...')
46 FILE_SAVED = 'Saved file {0} ({1}B).'
47 GREETINGS = 'Bye! :D'
48
49
50 class ErrorMessages:
51 NO_TARGET_LANG = 'Error: No target language was provided!'
52 NO_TOKEN_PROVIDED = ('Error: No token found! Copy-paste and run the '
53 'following command in your shell to login and '
54 'generate the token: \n\n\t{}\n\n. Watch out: In '
55 'order for the token to be valid, re-run the script '
56 'in the same shell after generating it!')
57 LOCALES_NOT_PRESENT = ('Error: The following languages are enabled in the '
58 'API, but not listed in locales: {0}! Please '
59 'remove them manually from project number {1} and '
60 'then re-run the script!')
61 FILENAME_TOO_LONG = ('The filename is too long: {0}! XTM only supports '
62 'up to {1} characters!')
63 CANT_RESOLVE_REMOTE_LANG = 'Cannot resolve remote locale: {0}'
64 EXISTENT_PROJECT = ('Error! There already exists an XTM project associated'
Vasily Kuznetsov 2018/09/24 16:32:11 What do you think about renaming this to PROJECT_E
Tudor Avram 2018/09/25 12:26:24 Done.
65 ' with this website (number {0})! If you want to '
66 'overwrite this, please delete the project id from '
67 'settings.ini and run this again.')
68 NO_PROJECT = 'Error! No project configured for {}!'
69 NO_TARGET_FILES_FOUND = ('Error: No target files were found in XTM! '
70 'Please generate them and then try again!')
71 COULD_NOT_SAVE_FILES = ('Error: Could not save the downloaded files to '
72 'disk!')
73
74
75 class WarningMessages:
76 UNSUPPORTED_LOCALE = ('The following locale is not supported: "{0}". '
Vasily Kuznetsov 2018/09/24 16:32:11 If you agree about EXISTENT_PROJECT -> PROJECT_EXI
Tudor Avram 2018/09/25 12:26:24 Done.
77 'Ignoring...')
78
79
80 PROJECT_NAME = {
81 'max_length': 150,
82 'invalid_chars': list('\\/:*?"<>|{}'),
83 'name_wildcard': '_',
84 }
85
86 TOKEN = {
87 'env_var': 'XTM_TOKEN',
88 'save_cmd': "export {0}='{1}'",
89 'creation_cmd': 'python -m cms.bin.xtm_translations login',
90 }
91
92 ARGUMENTS_HELP = {
93 'verbose': 'Whether the script will log its work to stderr or not.',
94 'project_id': 'The ID of the project we are working with. Will be '
95 'ignored if in "create" mode.',
96 'login': 'Mode used to generate and save an API token from username+pass.',
97 'project': 'Mode for handling projects: creation, files upload/ update/ '
98 'download.',
99 'project_source-dir': 'The source directory of the website.',
100 'project_create': {
101 'main': 'Sub-mode used to create a new project with XTM Cloud.',
102 'name': 'The name of the project will have once created.',
103 'desc': 'TBD',
104 'client_id': 'TBD',
105 'ref_id': 'TBD',
106 'workflow_id': 'TBD',
107 'source': 'The source language for this project. Default "en_US".',
108 'save-id': 'Whether to save the id of the project to settings.ini '
109 'or not. Default False.',
110 'no_upload': 'If set, the script will create the project without '
111 'uploading any files.',
112 },
113 'project_upload': {
114 'main': 'Sub-mode used to upload files to an XTM Cloud project.',
115 'no-overwrite': 'If set, the script will not overwrite the files '
116 'already present in the XTM environment.',
117 },
118 'project_download': 'Download the translation files from a project and '
119 'save them to disk.',
120 }
121
122 CONFIG = {
Vasily Kuznetsov 2018/09/24 16:32:11 Perhaps this and some previous bundles of constant
Tudor Avram 2018/09/25 12:26:24 Done.
123 'XTM_section': 'XTM',
124 'project_option': 'project_id',
125 'main_section': 'general',
126 'default_locale_option': 'defaultlocale',
127 }
128
129 SUPPORTED_LOCALES = (
130 'ab, aa_ET, ak, af_ZA, sq_AL, am_ET, am_ER, ar_AA, ar_AE,ar_BH, ar_DZ, '
131 'ar_EG, ar_EH, ar_IQ, ar_JO, ar_KW, ar_LB, ar_LY, ar_MA, ar_MR, ar_OM, '
132 'ar_PS, ar_QA, ar_SA, ar_SD, ar_SY, ar_TD, ar_TN, ar_YE, hy_AM, '
133 'hy_AM_arevela, hy_AM_arevmda, as_IN, ast_ES, ay_BO, az_AZ_Cyrl, '
134 'az_AZ_Latn, ba_RU, bal_IR, bh_IN, bi_VU, bs_BA_Cyrl, bs_BA_Latn, br_FR, '
135 'bsk, my_MM, be_BY, cal, ca_ES, ceb, cha, ny_MW, zh_CN, zh_TW, zh_HK, '
136 'zh_SG, chk, co_FR, hr_HR, hr_BA, cs_CZ, eu_ES, bn_IN, bn_BD, bg_BG, '
137 'ca_AD, dnj, da_DK, prs_AF, dv_IN, mis, nl_NL, en_US, en_GB, en_142, '
138 'en_CA, en_AU, en_NZ, en_ZA, en_CH, en_HK, en_IN, en_IE, en_SG, en_AE, '
139 'en_DE, en_NL, en_AT, en_NT, en_CY, en_KE, en_BS, en_MY, en_PK, en_PH, eo,'
140 ' et_EE, ee_GH, fo_FO, fj_FJ, fil_PH, fi_FI, nl_BE, fr_FR, fr_CA, fr_CH, '
141 'fr_BE, fr_LU, fr_MA, fr_SN, fr_CM, fy, fu, fat, gl_ES, ka_GE, kar, de_DE,'
142 ' de_AT, de_BE, de_CH, de_LU, de_NL, lb_LU, kl_GL, el_GR, el_CY, grc_GR, '
143 'grn, gu_IN, ht_HT, cnh, ha_NG, he_IL, hi_IN, hil, hmn, hmn_US, hu_HU, '
144 'haw, is_IS, ig, ilo, id_ID, ia, ie, iu, ium, ik, ga_IE, it_IT, it_CH, '
145 'ja_JP, jv_ID, ks, kk_KZ, kg_CG, rw_RW, ky, rn, sw_KE, km_KH, kn_IN, '
146 'kok_IN, tlh, ko_KR, kos, ku_TR, kmr, ckb, ku_IQ, lo_LA, la, lv_LV, ln_CG,'
147 ' lt_LT, mfe_MU, mk_MK, mg_MG, ms_MY, ms_SG, ml_IN, mt_MT, mi_NZ, mr_IN, '
148 'mah, mn_MN, sla_ME, mo_MD, na_NR, nv, nd_ZW, ne_NP, no_NO, nb_NO, nn_NO, '
149 'nso_ZA, nus, oc_FR, or_IN, om_ET, ota, pau, ps, ps_PK, fa_IR, pon, pl_PL,'
150 ' pt_PT, pt_BR, pt_MZ, pt_AO, pa_PA, pa_IN, pa_PK, qu_PE, qya, xr_MM, '
151 'rm_CH, ro_RO, ro_MD, ru_RU, ru_AM, ru_AZ, ru_GE, ru_MD, ru_UA, sm_WS, sg,'
152 ' sa_IN, sc_IT, gd_GB, st, tn_ZA, sr_YU, sr_RS_Cyrl, sr_ME_Cyrl, '
153 'sr_ME_Latn, sr_RS_Latn, sn, sjn, sd_PK, si_LK, ss, sk_SK, sl_SI, so_SO, '
154 'dsb_DE, hsb_DE, es_ES, es_AR, es_BO, es_CL, es_CO, es_CR, es_CU, es_DO, '
155 'es_EC, es_SV, es_GT, es_HN, es_419, es_MX, es_NI, es_PA, es_PY, es_PE, '
156 'es_PR, es_UY, es_US, es_VE, es_001, es_NT, swa, sw_SO, sw_TZ, sw_UG, '
157 'sv_SE, sv_FI, apd_SD, apd_SD_Latn, sun, syr_TR, tl_PH, tg_TJ, ta_IN, '
158 'ta_SG, ta_LK, tt_RU, te_IN, tet_ID, tet_TL, th_TH, bo, ti, to_TO, ts_ZA, '
159 'tn_BW, tr_TR, tk_TM, tw, uk_UA, ur_IN, ur_PK, ug_CN, uz_UZ_Cyrl, '
160 'uz_UZ_Latn, uz_AF, cy_GB, vi_VN, vo, wo, xh_ZA, xz_AF, yap, yi, yi_IL, '
161 'yi_US, yo_NG, czt, zu_ZA, kun, lua, sco_GB, sco_IE, fr_CG, zh_YUE, lug, '
162 'ogo, bbc, ksw, cfm, cmn, goyu, aii, cld, pdc'
163 ).split(', ')
164
165 FILENAMES = {
166 'max_length': 256,
167 'path_sep_rep': '___',
168 }
169
170 UNDER_ANALYSIS_MESSAGE = ('403: {"reason":"Project is under analysis. '
171 'Please wait for analysis end."}')
172
173 MAX_WAIT_TIME = 10
OLDNEW

Powered by Google App Engine
This is Rietveld