Generates localisation files
()
| 202 | |
| 203 | @task |
| 204 | def generate_locale(): |
| 205 | """ Generates localisation files """ |
| 206 | |
| 207 | EXCLUDE = ["BeautifulSoup.py", "module/gui", "module/cli", "web/locale", "web/ajax", "web/cnl", "web/pyload", |
| 208 | "setup.py"] |
| 209 | makepot("core", path("module"), EXCLUDE, "./pyLoadCore.py\n") |
| 210 | |
| 211 | makepot("gui", path("module") / "gui", [], includes="./pyLoadGui.py\n") |
| 212 | makepot("cli", path("module") / "cli", [], includes="./pyLoadCli.py\n") |
| 213 | makepot("setup", "", [], includes="./module/setup.py\n") |
| 214 | |
| 215 | EXCLUDE = ["ServerThread.py", "web/media/default"] |
| 216 | |
| 217 | # strings from js files |
| 218 | strings = set() |
| 219 | |
| 220 | for fi in path("module/web").walkfiles(): |
| 221 | if not fi.name.endswith(".js") and not fi.endswith(".coffee"): continue |
| 222 | with open(fi, "rb") as c: |
| 223 | content = c.read() |
| 224 | |
| 225 | strings.update(re.findall(r"_\s*\(\s*\"([^\"]+)", content)) |
| 226 | strings.update(re.findall(r"_\s*\(\s*\'([^\']+)", content)) |
| 227 | |
| 228 | trans = path("module") / "web" / "translations.js" |
| 229 | |
| 230 | with open(trans, "wb") as js: |
| 231 | for s in strings: |
| 232 | js.write('_("%s")\n' % s) |
| 233 | |
| 234 | makepot("django", path("module/web"), EXCLUDE, "./%s\n" % trans.relpath(), [".py", ".html"], ["--language=Python"]) |
| 235 | |
| 236 | trans.remove() |
| 237 | |
| 238 | path("includes.txt").remove() |
| 239 | |
| 240 | print "Locale generated" |
| 241 | |
| 242 | |
| 243 | @task |