MCPcopy
hub / github.com/django/django / _get_locale_dirs

Function _get_locale_dirs

scripts/manage_translations.py:145–175  ·  view source on GitHub ↗

Return a tuple (contrib name, absolute path) for all locale directories, optionally including the django core catalog. If resources list is not None, filter directories matching resources content.

(resources, include_core=True)

Source from the content-addressed store, hash-verified

143
144
145def _get_locale_dirs(resources, include_core=True):
146 """
147 Return a tuple (contrib name, absolute path) for all locale directories,
148 optionally including the django core catalog.
149 If resources list is not None, filter directories matching resources
150 content.
151 """
152 contrib_dir = os.path.join(os.getcwd(), "django", "contrib")
153 dirs = []
154
155 # Collect all locale directories
156 for contrib_name in os.listdir(contrib_dir):
157 path = os.path.join(contrib_dir, contrib_name, "locale")
158 if os.path.isdir(path):
159 dirs.append((contrib_name, path))
160 if contrib_name in HAVE_JS:
161 dirs.append(("%s-js" % contrib_name, path))
162 if include_core:
163 dirs.insert(0, ("core", os.path.join(os.getcwd(), "django", "conf", "locale")))
164
165 # Filter by resources, if any
166 if resources is not None:
167 res_names = [d[0] for d in dirs]
168 dirs = [ld for ld in dirs if ld[0] in resources]
169 if len(resources) > len(dirs):
170 print(
171 "You have specified some unknown resources. "
172 "Available resource names are: %s" % (", ".join(res_names),)
173 )
174 exit(1)
175 return dirs
176
177
178def _tx_resource_slug_for_name(name):

Callers 3

update_catalogsFunction · 0.85
lang_statsFunction · 0.85
fetchFunction · 0.85

Calls 4

insertMethod · 0.80
joinMethod · 0.45
listdirMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected