MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / _expand_lang

Function _expand_lang

tools/python-3.11.9-amd64/Lib/gettext.py:224–263  ·  view source on GitHub ↗
(loc)

Source from the content-addressed store, hash-verified

222
223
224def _expand_lang(loc):
225 import locale
226 loc = locale.normalize(loc)
227 COMPONENT_CODESET = 1 << 0
228 COMPONENT_TERRITORY = 1 << 1
229 COMPONENT_MODIFIER = 1 << 2
230 # split up the locale into its base components
231 mask = 0
232 pos = loc.find('@')
233 if pos >= 0:
234 modifier = loc[pos:]
235 loc = loc[:pos]
236 mask |= COMPONENT_MODIFIER
237 else:
238 modifier = ''
239 pos = loc.find('.')
240 if pos >= 0:
241 codeset = loc[pos:]
242 loc = loc[:pos]
243 mask |= COMPONENT_CODESET
244 else:
245 codeset = ''
246 pos = loc.find('_')
247 if pos >= 0:
248 territory = loc[pos:]
249 loc = loc[:pos]
250 mask |= COMPONENT_TERRITORY
251 else:
252 territory = ''
253 language = loc
254 ret = []
255 for i in range(mask+1):
256 if not (i & ~mask): # if all components for this combo exist ...
257 val = language
258 if i & COMPONENT_TERRITORY: val += territory
259 if i & COMPONENT_CODESET: val += codeset
260 if i & COMPONENT_MODIFIER: val += modifier
261 ret.append(val)
262 ret.reverse()
263 return ret
264
265
266class NullTranslations:

Callers 1

findFunction · 0.85

Calls 4

normalizeMethod · 0.45
findMethod · 0.45
appendMethod · 0.45
reverseMethod · 0.45

Tested by

no test coverage detected