138 """Fetch languages from peertube's search-index source code.
140 See videoLanguages_ in commit `8ed5c729 - Refactor and redesign client`_
142 .. _8ed5c729 - Refactor and redesign client:
143 https://framagit.org/framasoft/peertube/search-index/-/commit/8ed5c729
145 https://framagit.org/framasoft/peertube/search-index/-/commit/8ed5c729#3d8747f9a60695c367c70bb64efba8f403721fad_0_291
149 'https://framagit.org/framasoft/peertube/search-index/-/raw/master/client/src/components/Filters.vue',
155 print(
"ERROR: response from peertube is not OK.")
158 js_lang = re.search(
r"videoLanguages \(\)[^\n]+(.*?)\]", resp.text, re.DOTALL)
160 print(
"ERROR: can't determine languages from peertube")
163 for lang
in re.finditer(
r"\{ id: '([a-z]+)', label:", js_lang.group(1)):
164 eng_tag = lang.group(1)
171 sxng_tag = language_tag(babel.Locale.parse(eng_tag))
172 except babel.UnknownLocaleError:
173 print(
"ERROR: %s is unknown by babel" % eng_tag)
176 conflict = engine_traits.languages.get(sxng_tag)
178 if conflict != eng_tag:
179 print(
"CONFLICT: babel %s --> %s, %s" % (sxng_tag, conflict, eng_tag))
181 engine_traits.languages[sxng_tag] = eng_tag
183 engine_traits.languages[
'zh_Hans'] =
'zh'
184 engine_traits.languages[
'zh_Hant'] =
'zh'