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