Merge lp:~dholbach/help-app/1426304 into lp:~ubuntu-touch-coreapps-drivers/help-app/trunk
- 1426304
- Merge into trunk
| Status: | Merged |
|---|---|
| Merged at revision: | 67 |
| Proposed branch: | lp:~dholbach/help-app/1426304 |
| Merge into: | lp:~ubuntu-touch-coreapps-drivers/help-app/trunk |
| Diff against target: |
1083 lines (+391/-266) 10 files modified
edit-here/generate-pot (+1/-2) edit-here/generate-translations (+0/-1) edit-here/index.html (+4/-0) edit-here/po/de.po (+39/-26) edit-here/po/fr.po (+37/-25) edit-here/po/help.pot (+5/-5) edit-here/po/it.po (+37/-25) edit-here/po/pt.po (+38/-27) edit-here/po/ro.po (+37/-25) edit-here/translations.py (+193/-130) |
| To merge this branch: | bzr merge lp:~dholbach/help-app/1426304 |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| David Planella | Approve | ||
| Daniel Holbach (community) | Needs Fixing | ||
|
Review via email:
|
|||
Commit message
Description of the change
- 68. By Daniel Holbach
-
add require() function to simplify code a bit
- 69. By Daniel Holbach
-
update index.html with new languages
- 70. By Daniel Holbach
-
merge from trunk, resolve conflicts
- 71. By Daniel Holbach
-
update German translation, this will help as a test-case
- 72. By Daniel Holbach
-
omit untranslated 'Title:' line, as it would give us two 'Title:' lines
- 73. By Daniel Holbach
-
also bend links if the link title is translated
- 74. By Daniel Holbach
-
fix case where 'original_title in msgid' was not good enough, we need it exact
- 75. By Daniel Holbach
-
add Portoguese
| Daniel Holbach (dholbach) wrote : | # |
Ok, we decided to go without saving 'title_lines' anywhere, but just agree that the Title line is always the first. I'll add a piece of code in the "Title" line replacer which checks the line number.
Working on this now.
- 76. By Daniel Holbach
-
instead of doing internal bookkeeping, assume that the first line is the title_line - also error out, if we find a title line that doesn't have linenumber 1
| David Planella (dpm) wrote : | # |
Looks good to me, good work! I've just added an inline comment as a suggestion, but for me it's already good to go.
- 77. By Daniel Holbach
-
remove leftover print statement
| Daniel Holbach (dholbach) wrote : | # |
Fixed.
Preview Diff
| 1 | === modified file 'edit-here/generate-pot' |
| 2 | --- edit-here/generate-pot 2015-02-25 16:02:15 +0000 |
| 3 | +++ edit-here/generate-pot 2015-03-05 08:14:16 +0000 |
| 4 | @@ -10,8 +10,7 @@ |
| 5 | |
| 6 | def main(): |
| 7 | translations = Translations() |
| 8 | - translations.generate_pot_file() |
| 9 | - if not translations.update_po_files(): |
| 10 | + if not translations.generate_pot_file(): |
| 11 | sys.exit(1) |
| 12 | |
| 13 | if __name__ == '__main__': |
| 14 | |
| 15 | === modified file 'edit-here/generate-translations' |
| 16 | --- edit-here/generate-translations 2015-02-25 14:41:25 +0000 |
| 17 | +++ edit-here/generate-translations 2015-03-05 08:14:16 +0000 |
| 18 | @@ -9,7 +9,6 @@ |
| 19 | |
| 20 | def main(): |
| 21 | translations = Translations() |
| 22 | - translations.rewrite_links() |
| 23 | translations.generate_translations() |
| 24 | |
| 25 | |
| 26 | |
| 27 | === modified file 'edit-here/index.html' |
| 28 | --- edit-here/index.html 2015-02-26 14:25:16 +0000 |
| 29 | +++ edit-here/index.html 2015-03-05 08:14:16 +0000 |
| 30 | @@ -10,7 +10,11 @@ |
| 31 | <body> |
| 32 | <ul> |
| 33 | <li><a href="index.en-us.html">English</a></li> |
| 34 | + <li><a href="index.fr.html">French</a></li> |
| 35 | <li><a href="index.de.html">German</a></li> |
| 36 | + <li><a href="index.it.html">Italian</a></li> |
| 37 | + <li><a href="index.pt.html">Portuguese</a></li> |
| 38 | + <li><a href="index.ro.html">Romanian</a></li> |
| 39 | </ul> |
| 40 | </body> |
| 41 | </html> |
| 42 | |
| 43 | === modified file 'edit-here/po/de.po' |
| 44 | --- edit-here/po/de.po 2015-02-28 06:41:48 +0000 |
| 45 | +++ edit-here/po/de.po 2015-03-05 08:14:16 +0000 |
| 46 | @@ -2,7 +2,7 @@ |
| 47 | # Copyright (C) YEAR Free Software Foundation, Inc. |
| 48 | # This file is distributed under the same license as the PACKAGE package. |
| 49 | # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. |
| 50 | -# |
| 51 | +# |
| 52 | msgid "" |
| 53 | msgstr "" |
| 54 | "Project-Id-Version: PACKAGE VERSION\n" |
| 55 | @@ -11,17 +11,12 @@ |
| 56 | "PO-Revision-Date: 2015-02-27 03:52+0000\n" |
| 57 | "Last-Translator: Daniel Holbach <daniel.holbach@ubuntu.com>\n" |
| 58 | "Language-Team: LANGUAGE <LL@li.org>\n" |
| 59 | +"Language: \n" |
| 60 | "MIME-Version: 1.0\n" |
| 61 | "Content-Type: text/plain; charset=UTF-8\n" |
| 62 | "Content-Transfer-Encoding: 8bit\n" |
| 63 | +"X-Generator: Launchpad (build 17361)\n" |
| 64 | "X-Launchpad-Export-Date: 2015-02-28 06:41+0000\n" |
| 65 | -"X-Generator: Launchpad (build 17361)\n" |
| 66 | -"Language: \n" |
| 67 | - |
| 68 | -#. type: Plain text |
| 69 | -#: content/pages/faq.md:2 |
| 70 | -msgid "Title: Get your questions answered." |
| 71 | -msgstr "Title: Antworten auf Deine Fragen." |
| 72 | |
| 73 | #. type: Plain text |
| 74 | #: content/pages/faq.md:5 |
| 75 | @@ -43,11 +38,6 @@ |
| 76 | msgstr "..." |
| 77 | |
| 78 | #. type: Plain text |
| 79 | -#: content/pages/index.md:2 |
| 80 | -msgid "Title: Welcome to Help for Ubuntu for devices!" |
| 81 | -msgstr "Title: Willkommen bei der Hilfe für Ubuntu-Geräte!" |
| 82 | - |
| 83 | -#. type: Plain text |
| 84 | #: content/pages/index.md:5 |
| 85 | msgid "" |
| 86 | "The world-wide Ubuntu community wants to give you the best possible " |
| 87 | @@ -70,7 +60,8 @@ |
| 88 | #: content/pages/index.md:9 |
| 89 | msgid "links to get in touch with experts and other community members" |
| 90 | msgstr "" |
| 91 | -"Links, um mit anderen Community-Mitgliedern und Experten in Kontakt zu kommen" |
| 92 | +"Links, um mit anderen Community-Mitgliedern und Experten in Kontakt zu " |
| 93 | +"kommen" |
| 94 | |
| 95 | #. type: Plain text |
| 96 | #: content/pages/index.md:11 |
| 97 | @@ -81,17 +72,12 @@ |
| 98 | #: content/pages/index.md:12 |
| 99 | #, no-wrap |
| 100 | msgid "[Take me to the FAQ!]({filename}faq.md) \n" |
| 101 | -msgstr "[Gib mir die Antworten!]({filename}faq.md) \n" |
| 102 | +msgstr "[Gib mir die Antworten!]({filename}faq.de.md) \n" |
| 103 | |
| 104 | #. type: Plain text |
| 105 | #: content/pages/index.md:14 |
| 106 | msgid "[Get in touch]({filename}get-in-touch.md)" |
| 107 | -msgstr "[Kontakt]({filename}get-in-touch.md)" |
| 108 | - |
| 109 | -#. type: Plain text |
| 110 | -#: content/pages/apps.md:2 |
| 111 | -msgid "Title: FAQ - Apps" |
| 112 | -msgstr "Title: FAQ - Apps" |
| 113 | +msgstr "[Kontakt]({filename}get-in-touch.de.md)" |
| 114 | |
| 115 | #. type: Plain text |
| 116 | #: content/pages/apps.md:5 |
| 117 | @@ -138,11 +124,6 @@ |
| 118 | "---\n" |
| 119 | |
| 120 | #. type: Plain text |
| 121 | -#: content/pages/get-in-touch.md:2 |
| 122 | -msgid "Title: Get in touch" |
| 123 | -msgstr "Title: Kontakt" |
| 124 | - |
| 125 | -#. type: Plain text |
| 126 | #: content/pages/get-in-touch.md:7 |
| 127 | #, no-wrap |
| 128 | msgid "" |
| 129 | @@ -167,3 +148,35 @@ |
| 130 | "out about all the individual teams in Ubuntu, what they do, where they hang " |
| 131 | "out and how to get involved." |
| 132 | msgstr "" |
| 133 | + |
| 134 | +#. type: Plain text |
| 135 | +#: content/pages/faq.md:2 |
| 136 | +msgid "Get your questions answered." |
| 137 | +msgstr "Antworten auf Deine Fragen." |
| 138 | + |
| 139 | +#. type: Plain text |
| 140 | +#: content/pages/index.md:2 |
| 141 | +msgid "Welcome to Help for Ubuntu for devices!" |
| 142 | +msgstr "Willkommen zur Ubuntu Hilfe!" |
| 143 | + |
| 144 | +#. type: Plain text |
| 145 | +#: content/pages/apps.md:2 |
| 146 | +msgid "FAQ - Apps" |
| 147 | +msgstr "" |
| 148 | + |
| 149 | +#. type: Plain text |
| 150 | +#: content/pages/get-in-touch.md:2 |
| 151 | +msgid "Get in touch" |
| 152 | +msgstr "Kontakt" |
| 153 | + |
| 154 | +#~ msgid "Title: Get your questions answered." |
| 155 | +#~ msgstr "Title: Antworten auf Deine Fragen." |
| 156 | + |
| 157 | +#~ msgid "Title: Welcome to Help for Ubuntu for devices!" |
| 158 | +#~ msgstr "Title: Willkommen bei der Hilfe für Ubuntu-Geräte!" |
| 159 | + |
| 160 | +#~ msgid "Title: FAQ - Apps" |
| 161 | +#~ msgstr "Title: FAQ - Apps" |
| 162 | + |
| 163 | +#~ msgid "Title: Get in touch" |
| 164 | +#~ msgstr "Title: Kontakt" |
| 165 | |
| 166 | === modified file 'edit-here/po/fr.po' |
| 167 | --- edit-here/po/fr.po 2015-02-28 06:41:48 +0000 |
| 168 | +++ edit-here/po/fr.po 2015-03-05 08:14:16 +0000 |
| 169 | @@ -2,7 +2,7 @@ |
| 170 | # Copyright (c) 2015 Rosetta Contributors and Canonical Ltd 2015 |
| 171 | # This file is distributed under the same license as the ubuntu-devices-help package. |
| 172 | # FIRST AUTHOR <EMAIL@ADDRESS>, 2015. |
| 173 | -# |
| 174 | +# |
| 175 | msgid "" |
| 176 | msgstr "" |
| 177 | "Project-Id-Version: ubuntu-devices-help\n" |
| 178 | @@ -14,13 +14,8 @@ |
| 179 | "MIME-Version: 1.0\n" |
| 180 | "Content-Type: text/plain; charset=UTF-8\n" |
| 181 | "Content-Transfer-Encoding: 8bit\n" |
| 182 | +"X-Generator: Launchpad (build 17361)\n" |
| 183 | "X-Launchpad-Export-Date: 2015-02-28 06:41+0000\n" |
| 184 | -"X-Generator: Launchpad (build 17361)\n" |
| 185 | - |
| 186 | -#. type: Plain text |
| 187 | -#: content/pages/faq.md:2 |
| 188 | -msgid "Title: Get your questions answered." |
| 189 | -msgstr "" |
| 190 | |
| 191 | #. type: Plain text |
| 192 | #: content/pages/faq.md:5 |
| 193 | @@ -32,7 +27,7 @@ |
| 194 | #. type: Bullet: ' * ' |
| 195 | #: content/pages/faq.md:7 |
| 196 | msgid "[Apps]({filename}apps.md)" |
| 197 | -msgstr "" |
| 198 | +msgstr "[Apps]({filename}apps.fr.md)" |
| 199 | |
| 200 | #. type: Bullet: ' * ' |
| 201 | #: content/pages/faq.md:7 |
| 202 | @@ -40,11 +35,6 @@ |
| 203 | msgstr "" |
| 204 | |
| 205 | #. type: Plain text |
| 206 | -#: content/pages/index.md:2 |
| 207 | -msgid "Title: Welcome to Help for Ubuntu for devices!" |
| 208 | -msgstr "" |
| 209 | - |
| 210 | -#. type: Plain text |
| 211 | #: content/pages/index.md:5 |
| 212 | msgid "" |
| 213 | "The world-wide Ubuntu community wants to give you the best possible " |
| 214 | @@ -75,17 +65,12 @@ |
| 215 | #: content/pages/index.md:12 |
| 216 | #, no-wrap |
| 217 | msgid "[Take me to the FAQ!]({filename}faq.md) \n" |
| 218 | -msgstr "" |
| 219 | +msgstr "[Take me to the FAQ!]({filename}faq.fr.md) \n" |
| 220 | |
| 221 | #. type: Plain text |
| 222 | #: content/pages/index.md:14 |
| 223 | msgid "[Get in touch]({filename}get-in-touch.md)" |
| 224 | -msgstr "" |
| 225 | - |
| 226 | -#. type: Plain text |
| 227 | -#: content/pages/apps.md:2 |
| 228 | -msgid "Title: FAQ - Apps" |
| 229 | -msgstr "" |
| 230 | +msgstr "[Get in touch]({filename}get-in-touch.fr.md)" |
| 231 | |
| 232 | #. type: Plain text |
| 233 | #: content/pages/apps.md:5 |
| 234 | @@ -124,11 +109,6 @@ |
| 235 | msgstr "" |
| 236 | |
| 237 | #. type: Plain text |
| 238 | -#: content/pages/get-in-touch.md:2 |
| 239 | -msgid "Title: Get in touch" |
| 240 | -msgstr "" |
| 241 | - |
| 242 | -#. type: Plain text |
| 243 | #: content/pages/get-in-touch.md:7 |
| 244 | #, no-wrap |
| 245 | msgid "" |
| 246 | @@ -147,3 +127,35 @@ |
| 247 | "out about all the individual teams in Ubuntu, what they do, where they hang " |
| 248 | "out and how to get involved." |
| 249 | msgstr "" |
| 250 | + |
| 251 | +#. type: Plain text |
| 252 | +#: content/pages/faq.md:2 |
| 253 | +msgid "Get your questions answered." |
| 254 | +msgstr "" |
| 255 | + |
| 256 | +#. type: Plain text |
| 257 | +#: content/pages/index.md:2 |
| 258 | +msgid "Welcome to Help for Ubuntu for devices!" |
| 259 | +msgstr "" |
| 260 | + |
| 261 | +#. type: Plain text |
| 262 | +#: content/pages/apps.md:2 |
| 263 | +msgid "FAQ - Apps" |
| 264 | +msgstr "" |
| 265 | + |
| 266 | +#. type: Plain text |
| 267 | +#: content/pages/get-in-touch.md:2 |
| 268 | +msgid "Get in touch" |
| 269 | +msgstr "" |
| 270 | + |
| 271 | +#~ msgid "Title: Get your questions answered." |
| 272 | +#~ msgstr "" |
| 273 | + |
| 274 | +#~ msgid "Title: Welcome to Help for Ubuntu for devices!" |
| 275 | +#~ msgstr "" |
| 276 | + |
| 277 | +#~ msgid "Title: FAQ - Apps" |
| 278 | +#~ msgstr "" |
| 279 | + |
| 280 | +#~ msgid "Title: Get in touch" |
| 281 | +#~ msgstr "" |
| 282 | |
| 283 | === modified file 'edit-here/po/help.pot' |
| 284 | --- edit-here/po/help.pot 2015-02-26 14:28:46 +0000 |
| 285 | +++ edit-here/po/help.pot 2015-03-05 08:14:16 +0000 |
| 286 | @@ -2,7 +2,7 @@ |
| 287 | # Copyright (C) YEAR Free Software Foundation, Inc. |
| 288 | # This file is distributed under the same license as the PACKAGE package. |
| 289 | # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. |
| 290 | -# |
| 291 | +# |
| 292 | #, fuzzy |
| 293 | msgid "" |
| 294 | msgstr "" |
| 295 | @@ -18,7 +18,7 @@ |
| 296 | |
| 297 | #. type: Plain text |
| 298 | #: content/pages/faq.md:2 |
| 299 | -msgid "Title: Get your questions answered." |
| 300 | +msgid "Get your questions answered." |
| 301 | msgstr "" |
| 302 | |
| 303 | #. type: Plain text |
| 304 | @@ -40,7 +40,7 @@ |
| 305 | |
| 306 | #. type: Plain text |
| 307 | #: content/pages/index.md:2 |
| 308 | -msgid "Title: Welcome to Help for Ubuntu for devices!" |
| 309 | +msgid "Welcome to Help for Ubuntu for devices!" |
| 310 | msgstr "" |
| 311 | |
| 312 | #. type: Plain text |
| 313 | @@ -83,7 +83,7 @@ |
| 314 | |
| 315 | #. type: Plain text |
| 316 | #: content/pages/apps.md:2 |
| 317 | -msgid "Title: FAQ - Apps" |
| 318 | +msgid "FAQ - Apps" |
| 319 | msgstr "" |
| 320 | |
| 321 | #. type: Plain text |
| 322 | @@ -124,7 +124,7 @@ |
| 323 | |
| 324 | #. type: Plain text |
| 325 | #: content/pages/get-in-touch.md:2 |
| 326 | -msgid "Title: Get in touch" |
| 327 | +msgid "Get in touch" |
| 328 | msgstr "" |
| 329 | |
| 330 | #. type: Plain text |
| 331 | |
| 332 | === modified file 'edit-here/po/it.po' |
| 333 | --- edit-here/po/it.po 2015-03-02 06:02:11 +0000 |
| 334 | +++ edit-here/po/it.po 2015-03-05 08:14:16 +0000 |
| 335 | @@ -2,7 +2,7 @@ |
| 336 | # Copyright (c) 2015 Rosetta Contributors and Canonical Ltd 2015 |
| 337 | # This file is distributed under the same license as the ubuntu-devices-help package. |
| 338 | # FIRST AUTHOR <EMAIL@ADDRESS>, 2015. |
| 339 | -# |
| 340 | +# |
| 341 | msgid "" |
| 342 | msgstr "" |
| 343 | "Project-Id-Version: ubuntu-devices-help\n" |
| 344 | @@ -14,13 +14,8 @@ |
| 345 | "MIME-Version: 1.0\n" |
| 346 | "Content-Type: text/plain; charset=UTF-8\n" |
| 347 | "Content-Transfer-Encoding: 8bit\n" |
| 348 | +"X-Generator: Launchpad (build 17361)\n" |
| 349 | "X-Launchpad-Export-Date: 2015-03-02 06:02+0000\n" |
| 350 | -"X-Generator: Launchpad (build 17361)\n" |
| 351 | - |
| 352 | -#. type: Plain text |
| 353 | -#: content/pages/faq.md:2 |
| 354 | -msgid "Title: Get your questions answered." |
| 355 | -msgstr "" |
| 356 | |
| 357 | #. type: Plain text |
| 358 | #: content/pages/faq.md:5 |
| 359 | @@ -32,7 +27,7 @@ |
| 360 | #. type: Bullet: ' * ' |
| 361 | #: content/pages/faq.md:7 |
| 362 | msgid "[Apps]({filename}apps.md)" |
| 363 | -msgstr "" |
| 364 | +msgstr "[Apps]({filename}apps.it.md)" |
| 365 | |
| 366 | #. type: Bullet: ' * ' |
| 367 | #: content/pages/faq.md:7 |
| 368 | @@ -40,11 +35,6 @@ |
| 369 | msgstr "" |
| 370 | |
| 371 | #. type: Plain text |
| 372 | -#: content/pages/index.md:2 |
| 373 | -msgid "Title: Welcome to Help for Ubuntu for devices!" |
| 374 | -msgstr "" |
| 375 | - |
| 376 | -#. type: Plain text |
| 377 | #: content/pages/index.md:5 |
| 378 | msgid "" |
| 379 | "The world-wide Ubuntu community wants to give you the best possible " |
| 380 | @@ -75,17 +65,12 @@ |
| 381 | #: content/pages/index.md:12 |
| 382 | #, no-wrap |
| 383 | msgid "[Take me to the FAQ!]({filename}faq.md) \n" |
| 384 | -msgstr "" |
| 385 | +msgstr "[Take me to the FAQ!]({filename}faq.it.md) \n" |
| 386 | |
| 387 | #. type: Plain text |
| 388 | #: content/pages/index.md:14 |
| 389 | msgid "[Get in touch]({filename}get-in-touch.md)" |
| 390 | -msgstr "" |
| 391 | - |
| 392 | -#. type: Plain text |
| 393 | -#: content/pages/apps.md:2 |
| 394 | -msgid "Title: FAQ - Apps" |
| 395 | -msgstr "" |
| 396 | +msgstr "[Get in touch]({filename}get-in-touch.it.md)" |
| 397 | |
| 398 | #. type: Plain text |
| 399 | #: content/pages/apps.md:5 |
| 400 | @@ -124,11 +109,6 @@ |
| 401 | msgstr "" |
| 402 | |
| 403 | #. type: Plain text |
| 404 | -#: content/pages/get-in-touch.md:2 |
| 405 | -msgid "Title: Get in touch" |
| 406 | -msgstr "" |
| 407 | - |
| 408 | -#. type: Plain text |
| 409 | #: content/pages/get-in-touch.md:7 |
| 410 | #, no-wrap |
| 411 | msgid "" |
| 412 | @@ -147,3 +127,35 @@ |
| 413 | "out about all the individual teams in Ubuntu, what they do, where they hang " |
| 414 | "out and how to get involved." |
| 415 | msgstr "" |
| 416 | + |
| 417 | +#. type: Plain text |
| 418 | +#: content/pages/faq.md:2 |
| 419 | +msgid "Get your questions answered." |
| 420 | +msgstr "" |
| 421 | + |
| 422 | +#. type: Plain text |
| 423 | +#: content/pages/index.md:2 |
| 424 | +msgid "Welcome to Help for Ubuntu for devices!" |
| 425 | +msgstr "" |
| 426 | + |
| 427 | +#. type: Plain text |
| 428 | +#: content/pages/apps.md:2 |
| 429 | +msgid "FAQ - Apps" |
| 430 | +msgstr "" |
| 431 | + |
| 432 | +#. type: Plain text |
| 433 | +#: content/pages/get-in-touch.md:2 |
| 434 | +msgid "Get in touch" |
| 435 | +msgstr "" |
| 436 | + |
| 437 | +#~ msgid "Title: Get your questions answered." |
| 438 | +#~ msgstr "" |
| 439 | + |
| 440 | +#~ msgid "Title: Welcome to Help for Ubuntu for devices!" |
| 441 | +#~ msgstr "" |
| 442 | + |
| 443 | +#~ msgid "Title: FAQ - Apps" |
| 444 | +#~ msgstr "" |
| 445 | + |
| 446 | +#~ msgid "Title: Get in touch" |
| 447 | +#~ msgstr "" |
| 448 | |
| 449 | === modified file 'edit-here/po/pt.po' |
| 450 | --- edit-here/po/pt.po 2015-03-02 16:56:02 +0000 |
| 451 | +++ edit-here/po/pt.po 2015-03-05 08:14:16 +0000 |
| 452 | @@ -2,7 +2,7 @@ |
| 453 | # Copyright (c) 2015 Rosetta Contributors and Canonical Ltd 2015 |
| 454 | # This file is distributed under the same license as the ubuntu-devices-help package. |
| 455 | # FIRST AUTHOR <EMAIL@ADDRESS>, 2015. |
| 456 | -# |
| 457 | +# |
| 458 | msgid "" |
| 459 | msgstr "" |
| 460 | "Project-Id-Version: ubuntu-devices-help\n" |
| 461 | @@ -14,13 +14,8 @@ |
| 462 | "MIME-Version: 1.0\n" |
| 463 | "Content-Type: text/plain; charset=UTF-8\n" |
| 464 | "Content-Transfer-Encoding: 8bit\n" |
| 465 | +"X-Generator: Launchpad (build 17361)\n" |
| 466 | "X-Launchpad-Export-Date: 2015-03-01 05:48+0000\n" |
| 467 | -"X-Generator: Launchpad (build 17361)\n" |
| 468 | - |
| 469 | -#. type: Plain text |
| 470 | -#: content/pages/faq.md:2 |
| 471 | -msgid "Title: Get your questions answered." |
| 472 | -msgstr "Title: Ter resposta para as suas questões." |
| 473 | |
| 474 | #. type: Plain text |
| 475 | #: content/pages/faq.md:5 |
| 476 | @@ -34,7 +29,7 @@ |
| 477 | #. type: Bullet: ' * ' |
| 478 | #: content/pages/faq.md:7 |
| 479 | msgid "[Apps]({filename}apps.md)" |
| 480 | -msgstr "[Apps]({filename}apps.md)" |
| 481 | +msgstr "[Apps]({filename}apps.pt.md)" |
| 482 | |
| 483 | #. type: Bullet: ' * ' |
| 484 | #: content/pages/faq.md:7 |
| 485 | @@ -42,11 +37,6 @@ |
| 486 | msgstr "..." |
| 487 | |
| 488 | #. type: Plain text |
| 489 | -#: content/pages/index.md:2 |
| 490 | -msgid "Title: Welcome to Help for Ubuntu for devices!" |
| 491 | -msgstr "Title: Bem-vindo à Ajuda de Ubuntu para dispositivos!" |
| 492 | - |
| 493 | -#. type: Plain text |
| 494 | #: content/pages/index.md:5 |
| 495 | msgid "" |
| 496 | "The world-wide Ubuntu community wants to give you the best possible " |
| 497 | @@ -80,17 +70,12 @@ |
| 498 | #: content/pages/index.md:12 |
| 499 | #, no-wrap |
| 500 | msgid "[Take me to the FAQ!]({filename}faq.md) \n" |
| 501 | -msgstr "[Ir para perguntas mais frequentes!]({filename}faq.md) \n" |
| 502 | +msgstr "[Ir para perguntas mais frequentes!]({filename}faq.pt.md) \n" |
| 503 | |
| 504 | #. type: Plain text |
| 505 | #: content/pages/index.md:14 |
| 506 | msgid "[Get in touch]({filename}get-in-touch.md)" |
| 507 | -msgstr "[Entrar em contacto]({filename}get-in-touch.md)" |
| 508 | - |
| 509 | -#. type: Plain text |
| 510 | -#: content/pages/apps.md:2 |
| 511 | -msgid "Title: FAQ - Apps" |
| 512 | -msgstr "Title: Perguntas mais frequentes - Aplicações" |
| 513 | +msgstr "[Entrar em contacto]({filename}get-in-touch.pt.md)" |
| 514 | |
| 515 | #. type: Plain text |
| 516 | #: content/pages/apps.md:5 |
| 517 | @@ -136,11 +121,6 @@ |
| 518 | "---\n" |
| 519 | |
| 520 | #. type: Plain text |
| 521 | -#: content/pages/get-in-touch.md:2 |
| 522 | -msgid "Title: Get in touch" |
| 523 | -msgstr "Title: Entre em contacto" |
| 524 | - |
| 525 | -#. type: Plain text |
| 526 | #: content/pages/get-in-touch.md:7 |
| 527 | #, no-wrap |
| 528 | msgid "" |
| 529 | @@ -150,8 +130,7 @@ |
| 530 | "collaboratively-edited question and answer site for Ubuntu users and \n" |
| 531 | "developers. 100% free, no registration required. \n" |
| 532 | msgstr "" |
| 533 | -"O Ubuntu tem uma grande comunidade . Pode facilmente entrar em contacto com " |
| 534 | -"peritos e\n" |
| 535 | +"O Ubuntu tem uma grande comunidade . Pode facilmente entrar em contacto com peritos e\n" |
| 536 | "outros entusiastas. Um bom modo de o fazer, particularmente se**tiver \n" |
| 537 | "questões**, é através [AskUbuntu](http://www.askubuntu.com). É uma \n" |
| 538 | " página de perguntas e respostas colaborativa para utilizadores Ubuntu e \n" |
| 539 | @@ -169,3 +148,35 @@ |
| 540 | "Community Website](http://community.ubuntu.com/). Pode facilmente encontrar " |
| 541 | "tudo sobre as equipas individuais no Ubuntu, o que fazem, onde se encontram " |
| 542 | "e sobre como se envolver." |
| 543 | + |
| 544 | +#. type: Plain text |
| 545 | +#: content/pages/faq.md:2 |
| 546 | +msgid "Get your questions answered." |
| 547 | +msgstr "" |
| 548 | + |
| 549 | +#. type: Plain text |
| 550 | +#: content/pages/index.md:2 |
| 551 | +msgid "Welcome to Help for Ubuntu for devices!" |
| 552 | +msgstr "" |
| 553 | + |
| 554 | +#. type: Plain text |
| 555 | +#: content/pages/apps.md:2 |
| 556 | +msgid "FAQ - Apps" |
| 557 | +msgstr "" |
| 558 | + |
| 559 | +#. type: Plain text |
| 560 | +#: content/pages/get-in-touch.md:2 |
| 561 | +msgid "Get in touch" |
| 562 | +msgstr "" |
| 563 | + |
| 564 | +#~ msgid "Title: Get your questions answered." |
| 565 | +#~ msgstr "Título: Ter resposta para as suas questões." |
| 566 | + |
| 567 | +#~ msgid "Title: Welcome to Help for Ubuntu for devices!" |
| 568 | +#~ msgstr "Título: Bem-vindo à Ajuda de Ubuntu para dispositivos!" |
| 569 | + |
| 570 | +#~ msgid "Title: FAQ - Apps" |
| 571 | +#~ msgstr "Título: Perguntas mais frequentes - Aplicações" |
| 572 | + |
| 573 | +#~ msgid "Title: Get in touch" |
| 574 | +#~ msgstr "Título: Entre em contacto" |
| 575 | |
| 576 | === modified file 'edit-here/po/ro.po' |
| 577 | --- edit-here/po/ro.po 2015-02-28 06:41:48 +0000 |
| 578 | +++ edit-here/po/ro.po 2015-03-05 08:14:16 +0000 |
| 579 | @@ -2,7 +2,7 @@ |
| 580 | # Copyright (c) 2015 Rosetta Contributors and Canonical Ltd 2015 |
| 581 | # This file is distributed under the same license as the ubuntu-devices-help package. |
| 582 | # FIRST AUTHOR <EMAIL@ADDRESS>, 2015. |
| 583 | -# |
| 584 | +# |
| 585 | msgid "" |
| 586 | msgstr "" |
| 587 | "Project-Id-Version: ubuntu-devices-help\n" |
| 588 | @@ -14,13 +14,8 @@ |
| 589 | "MIME-Version: 1.0\n" |
| 590 | "Content-Type: text/plain; charset=UTF-8\n" |
| 591 | "Content-Transfer-Encoding: 8bit\n" |
| 592 | +"X-Generator: Launchpad (build 17361)\n" |
| 593 | "X-Launchpad-Export-Date: 2015-02-28 06:41+0000\n" |
| 594 | -"X-Generator: Launchpad (build 17361)\n" |
| 595 | - |
| 596 | -#. type: Plain text |
| 597 | -#: content/pages/faq.md:2 |
| 598 | -msgid "Title: Get your questions answered." |
| 599 | -msgstr "" |
| 600 | |
| 601 | #. type: Plain text |
| 602 | #: content/pages/faq.md:5 |
| 603 | @@ -32,7 +27,7 @@ |
| 604 | #. type: Bullet: ' * ' |
| 605 | #: content/pages/faq.md:7 |
| 606 | msgid "[Apps]({filename}apps.md)" |
| 607 | -msgstr "" |
| 608 | +msgstr "[Apps]({filename}apps.ro.md)" |
| 609 | |
| 610 | #. type: Bullet: ' * ' |
| 611 | #: content/pages/faq.md:7 |
| 612 | @@ -40,11 +35,6 @@ |
| 613 | msgstr "" |
| 614 | |
| 615 | #. type: Plain text |
| 616 | -#: content/pages/index.md:2 |
| 617 | -msgid "Title: Welcome to Help for Ubuntu for devices!" |
| 618 | -msgstr "" |
| 619 | - |
| 620 | -#. type: Plain text |
| 621 | #: content/pages/index.md:5 |
| 622 | msgid "" |
| 623 | "The world-wide Ubuntu community wants to give you the best possible " |
| 624 | @@ -75,17 +65,12 @@ |
| 625 | #: content/pages/index.md:12 |
| 626 | #, no-wrap |
| 627 | msgid "[Take me to the FAQ!]({filename}faq.md) \n" |
| 628 | -msgstr "" |
| 629 | +msgstr "[Take me to the FAQ!]({filename}faq.ro.md) \n" |
| 630 | |
| 631 | #. type: Plain text |
| 632 | #: content/pages/index.md:14 |
| 633 | msgid "[Get in touch]({filename}get-in-touch.md)" |
| 634 | -msgstr "" |
| 635 | - |
| 636 | -#. type: Plain text |
| 637 | -#: content/pages/apps.md:2 |
| 638 | -msgid "Title: FAQ - Apps" |
| 639 | -msgstr "" |
| 640 | +msgstr "[Get in touch]({filename}get-in-touch.ro.md)" |
| 641 | |
| 642 | #. type: Plain text |
| 643 | #: content/pages/apps.md:5 |
| 644 | @@ -124,11 +109,6 @@ |
| 645 | msgstr "" |
| 646 | |
| 647 | #. type: Plain text |
| 648 | -#: content/pages/get-in-touch.md:2 |
| 649 | -msgid "Title: Get in touch" |
| 650 | -msgstr "" |
| 651 | - |
| 652 | -#. type: Plain text |
| 653 | #: content/pages/get-in-touch.md:7 |
| 654 | #, no-wrap |
| 655 | msgid "" |
| 656 | @@ -147,3 +127,35 @@ |
| 657 | "out about all the individual teams in Ubuntu, what they do, where they hang " |
| 658 | "out and how to get involved." |
| 659 | msgstr "" |
| 660 | + |
| 661 | +#. type: Plain text |
| 662 | +#: content/pages/faq.md:2 |
| 663 | +msgid "Get your questions answered." |
| 664 | +msgstr "" |
| 665 | + |
| 666 | +#. type: Plain text |
| 667 | +#: content/pages/index.md:2 |
| 668 | +msgid "Welcome to Help for Ubuntu for devices!" |
| 669 | +msgstr "" |
| 670 | + |
| 671 | +#. type: Plain text |
| 672 | +#: content/pages/apps.md:2 |
| 673 | +msgid "FAQ - Apps" |
| 674 | +msgstr "" |
| 675 | + |
| 676 | +#. type: Plain text |
| 677 | +#: content/pages/get-in-touch.md:2 |
| 678 | +msgid "Get in touch" |
| 679 | +msgstr "" |
| 680 | + |
| 681 | +#~ msgid "Title: Get your questions answered." |
| 682 | +#~ msgstr "" |
| 683 | + |
| 684 | +#~ msgid "Title: Welcome to Help for Ubuntu for devices!" |
| 685 | +#~ msgstr "" |
| 686 | + |
| 687 | +#~ msgid "Title: FAQ - Apps" |
| 688 | +#~ msgstr "" |
| 689 | + |
| 690 | +#~ msgid "Title: Get in touch" |
| 691 | +#~ msgstr "" |
| 692 | |
| 693 | === modified file 'edit-here/translations.py' |
| 694 | --- edit-here/translations.py 2015-02-26 15:56:31 +0000 |
| 695 | +++ edit-here/translations.py 2015-03-05 08:14:16 +0000 |
| 696 | @@ -7,12 +7,16 @@ |
| 697 | import subprocess |
| 698 | import sys |
| 699 | |
| 700 | + |
| 701 | +def require(package): |
| 702 | + print('Missing prerequisites. Please run: ' |
| 703 | + '"sudo apt install %s"' % package) |
| 704 | + sys.exit(1) |
| 705 | + |
| 706 | try: |
| 707 | import polib |
| 708 | except ImportError: |
| 709 | - print('Missing prerequisites. Please run: ' |
| 710 | - '"sudo apt install python3-polib"') |
| 711 | - sys.exit(1) |
| 712 | + require('python3-polib') |
| 713 | |
| 714 | from pelicanconf import PATH |
| 715 | |
| 716 | @@ -26,17 +30,22 @@ |
| 717 | ) |
| 718 | |
| 719 | |
| 720 | +def find_bcp47_code(gettext_code): |
| 721 | + if gettext_code not in [c[0] for c in BCP47_OVERRIDES]: |
| 722 | + return gettext_code.lower().replace('_', '-') |
| 723 | + return [c[1] for c in BCP47_OVERRIDES |
| 724 | + if c[0] == gettext_code][0] |
| 725 | + |
| 726 | + |
| 727 | class PO4A(object): |
| 728 | - def __init__(self, pot_file): |
| 729 | + def __init__(self): |
| 730 | self.default_args = [ |
| 731 | '-f', 'text', |
| 732 | '-o', 'markdown', |
| 733 | '-M', 'utf-8', |
| 734 | ] |
| 735 | - self.pot_file = pot_file |
| 736 | if not shutil.which('po4a'): |
| 737 | - print('Missing prerequisites. Please run: "sudo apt install po4a"') |
| 738 | - sys.exit(1) |
| 739 | + require('po4a') |
| 740 | |
| 741 | def run(self, po4a_command, additional_args, with_output=False): |
| 742 | args = copy.copy(self.default_args) |
| 743 | @@ -47,163 +56,217 @@ |
| 744 | ret = subprocess.call([po4a_command]+args) |
| 745 | return ret |
| 746 | |
| 747 | - def gettextize(self, documents): |
| 748 | + def gettextize(self, document_fns, pot_file): |
| 749 | args = [] |
| 750 | - for document in documents: |
| 751 | - args += ['-m', document] |
| 752 | + for document_fn in document_fns: |
| 753 | + args += ['-m', document_fn] |
| 754 | args += [ |
| 755 | - '-p', self.pot_file, |
| 756 | + '-p', pot_file, |
| 757 | '-L', 'utf-8', |
| 758 | ] |
| 759 | - return self.run('po4a-gettextize', args) |
| 760 | - |
| 761 | - def updatepo(self, langs, documents): |
| 762 | - for lang in langs: |
| 763 | - args = [] |
| 764 | - for document in documents: |
| 765 | - args += ['-m', document] |
| 766 | - args += ['-p', lang.file_name] |
| 767 | - ret = self.run('po4a-updatepo', args) |
| 768 | - if ret: |
| 769 | - return False |
| 770 | - return True |
| 771 | - |
| 772 | - def translate(self, doc, lang): |
| 773 | + ret = self.run('po4a-gettextize', args) |
| 774 | + return (not ret) |
| 775 | + |
| 776 | + def translate(self, doc, po_fn): |
| 777 | args = [ |
| 778 | '-k', TRANSLATION_COMPLETION_PERCENTAGE, |
| 779 | '-m', doc, |
| 780 | - '-p', lang.file_name, |
| 781 | + '-p', po_fn, |
| 782 | '-L', 'utf-8', |
| 783 | ] |
| 784 | return self.run('po4a-translate', args, with_output=True) |
| 785 | |
| 786 | |
| 787 | +class POFile(object): |
| 788 | + def __init__(self, po_fn): |
| 789 | + self.po_fn = po_fn |
| 790 | + self.pofile = polib.pofile(po_fn) |
| 791 | + |
| 792 | + def merge(self, pot_file_ob): |
| 793 | + self.pofile.merge(pot_file_ob) |
| 794 | + |
| 795 | + def save(self): |
| 796 | + self.pofile.save(self.po_fn) |
| 797 | + |
| 798 | + def find_in_msgid(self, find_str, translated=True, fuzzy=True, |
| 799 | + untranslated=True): |
| 800 | + entries = [] |
| 801 | + if translated: |
| 802 | + entries += self.pofile.translated_entries() |
| 803 | + if fuzzy: |
| 804 | + entries += self.pofile.fuzzy_entries() |
| 805 | + if untranslated: |
| 806 | + entries += self.pofile.untranslated_entries() |
| 807 | + results = [] |
| 808 | + for entry in entries: |
| 809 | + if find_str in entry.msgid: |
| 810 | + results += [entry] |
| 811 | + return results |
| 812 | + |
| 813 | + def replace_title_lines(self): |
| 814 | + results = {} |
| 815 | + for entry in self.find_in_msgid('Title: '): |
| 816 | + if entry.msgid.startswith('Title: '): |
| 817 | + if entry.linenum != 1: |
| 818 | + print('Title line "%s" found, but at linenum "%s", ' |
| 819 | + 'not 1.' % (entry.msgid, entry.linenum)) |
| 820 | + return False |
| 821 | + entry.msgid = entry.msgid.replace('Title: ', '') |
| 822 | + fn = entry.occurrences[0][0] |
| 823 | + results[fn] = entry.msgid |
| 824 | + if self.po_fn.endswith('.po'): |
| 825 | + entry.msgstr = '' |
| 826 | + self.save() |
| 827 | + return True |
| 828 | + |
| 829 | + def rewrite_links(self, documents, bcp47): |
| 830 | + link_regex = r'\[.+?\]\(\{filename\}(.+?)\)' |
| 831 | + for entry in self.find_in_msgid('{filename}'): |
| 832 | + link_msgid = re.findall(link_regex, entry.msgid)[0] |
| 833 | + link_msgstr = list(re.findall(link_regex, entry.msgstr)) |
| 834 | + translated_doc_fn = os.path.basename( |
| 835 | + documents.translated_doc_fn(link_msgid, bcp47)) |
| 836 | + if not link_msgstr: |
| 837 | + entry.msgstr = entry.msgid |
| 838 | + link_msgstr = [link_msgid] |
| 839 | + entry.msgstr = entry.msgstr.replace(link_msgstr[0], |
| 840 | + translated_doc_fn) |
| 841 | + self.save() |
| 842 | + |
| 843 | + def find_translated_title_line(self, original_title): |
| 844 | + for entry in self.find_in_msgid(original_title): |
| 845 | + if entry.msgid == original_title: |
| 846 | + if entry.msgstr: |
| 847 | + return entry.msgstr |
| 848 | + return entry.msgid |
| 849 | + |
| 850 | + |
| 851 | +class PO(object): |
| 852 | + def __init__(self, po4a): |
| 853 | + self.translations_dir = os.path.abspath(os.path.join(PATH, '../po')) |
| 854 | + self.fake_lang_code = 'en_US' |
| 855 | + self.fake_po_fn = os.path.join(self.translations_dir, |
| 856 | + '%s.po' % self.fake_lang_code) |
| 857 | + self.pot_fn = os.path.join(self.translations_dir, 'help.pot') |
| 858 | + self.pot_file_ob = POFile(self.pot_fn) |
| 859 | + self.po4a = po4a |
| 860 | + self.langs = {} |
| 861 | + for po_fn in glob.glob(self.translations_dir+'/*.po'): |
| 862 | + self.add_language(po_fn) |
| 863 | + |
| 864 | + def add_language(self, po_fn): |
| 865 | + gettext_code = os.path.basename(po_fn).split('.po')[0] |
| 866 | + self.langs[po_fn] = { |
| 867 | + 'bcp47': find_bcp47_code(gettext_code), |
| 868 | + 'gettext_code': gettext_code, |
| 869 | + 'pofile': None, |
| 870 | + } |
| 871 | + |
| 872 | + def _remove_fake_po_file(self): |
| 873 | + if os.path.exists(self.fake_po_fn): |
| 874 | + os.remove(self.fake_po_fn) |
| 875 | + |
| 876 | + def __del__(self): |
| 877 | + self._remove_fake_po_file() |
| 878 | + |
| 879 | + def load_pofile(self, po_fn): |
| 880 | + if not self.langs[po_fn]['pofile']: |
| 881 | + self.langs[po_fn]['pofile'] = POFile(po_fn) |
| 882 | + |
| 883 | + def generate_pot_file(self, documents): |
| 884 | + if not self.po4a.gettextize(documents.docs, self.pot_fn): |
| 885 | + return False |
| 886 | + if not self.pot_file_ob.replace_title_lines(): |
| 887 | + return False |
| 888 | + for po_fn in self.langs: |
| 889 | + self.load_pofile(po_fn) |
| 890 | + self.langs[po_fn]['pofile'].merge(self.pot_file_ob.pofile) |
| 891 | + if not self.langs[po_fn]['pofile'].replace_title_lines(): |
| 892 | + return False |
| 893 | + return True |
| 894 | + |
| 895 | + # we generate a fake translation for en-US which is going to be |
| 896 | + # the default |
| 897 | + def generate_fake_pofile(self): |
| 898 | + self._remove_fake_po_file() |
| 899 | + shutil.copy(self.pot_fn, self.fake_po_fn) |
| 900 | + self.add_language(self.fake_po_fn) |
| 901 | + |
| 902 | + def find_translated_title_line(self, original_title, po_fn): |
| 903 | + return self.langs[po_fn]['pofile'].find_translated_title_line( |
| 904 | + original_title) |
| 905 | + |
| 906 | + def rewrite_links(self, documents): |
| 907 | + for po_fn in self.langs: |
| 908 | + self.load_pofile(po_fn) |
| 909 | + self.langs[po_fn]['pofile'].rewrite_links( |
| 910 | + documents, self.langs[po_fn]['bcp47']) |
| 911 | + |
| 912 | + |
| 913 | class Documents(object): |
| 914 | def __init__(self): |
| 915 | self.docs = [] |
| 916 | - for dirpath, dirnames, filenames in os.walk(PATH): |
| 917 | - for filename in filenames: |
| 918 | - self.docs += [os.path.join(dirpath, filename)] |
| 919 | + for dirpath, dirnames, fns in os.walk(PATH): |
| 920 | + for fn in fns: |
| 921 | + fn = os.path.relpath(os.path.join(dirpath, fn), |
| 922 | + os.path.join(PATH, '..')) |
| 923 | + self.docs += [fn] |
| 924 | |
| 925 | - def translated_doc(self, file_name, lang): |
| 926 | + def translated_doc_fn(self, fn, bcp47_code): |
| 927 | match = [doc for doc in self.docs |
| 928 | - if os.path.basename(doc) == os.path.basename(file_name)] |
| 929 | + if os.path.basename(doc) == os.path.basename(fn)] |
| 930 | if not match: |
| 931 | return None |
| 932 | return '%s.%s.md' % (match[0].split('.md')[0], |
| 933 | - lang.bcp47_code) |
| 934 | - |
| 935 | - def _call_po4a_translate(self, doc, lang, po4a): |
| 936 | - res = po4a.translate(doc, lang) |
| 937 | - output = codecs.decode(res.communicate()[0]) |
| 938 | - broken_title_line = [line for line in output.split('\n') |
| 939 | - if line.lower().startswith('title:')][0] |
| 940 | - rest = [line for line in output.split('\n') |
| 941 | - if not line.lower().startswith('title')] |
| 942 | - output = '\n'.join(rest) |
| 943 | - return (broken_title_line, output) |
| 944 | - |
| 945 | - def write_translated_markdown(self, lang, po4a): |
| 946 | - for doc in self.docs: |
| 947 | - (broken_title_line, output) = \ |
| 948 | - self._call_po4a_translate(doc, lang, po4a) |
| 949 | - new_path = self.translated_doc(doc, lang) |
| 950 | - text = "%s\nDate:\n\n" % (broken_title_line) |
| 951 | - text += output |
| 952 | - if os.path.exists(new_path): |
| 953 | - os.remove(new_path) |
| 954 | - if not os.path.exists(os.path.dirname(new_path)): |
| 955 | - os.makedirs(os.path.dirname(new_path)) |
| 956 | - with open(new_path, 'w', encoding='utf-8') as f: |
| 957 | - f.write(text) |
| 958 | - |
| 959 | - |
| 960 | -class Language(object): |
| 961 | - def __init__(self, po_file, documents): |
| 962 | - self.file_name = po_file |
| 963 | - self.gettext_code = os.path.basename(po_file).split('.po')[0] |
| 964 | - self.bcp47_code = self._find_bcp47_code() |
| 965 | - self.documents = documents |
| 966 | - |
| 967 | - def _find_bcp47_code(self): |
| 968 | - if self.gettext_code not in [c[0] for c in BCP47_OVERRIDES]: |
| 969 | - return self.gettext_code.lower().replace('_', '-') |
| 970 | - return [c[1] for c in BCP47_OVERRIDES |
| 971 | - if c[0] == self.gettext_code][0] |
| 972 | - |
| 973 | - def rewrite_links(self): |
| 974 | - po_file = polib.pofile(self.file_name) |
| 975 | - link_regex = r'\[.+?\]\(\{filename\}(.+?)\)' |
| 976 | - for entry_group in [po_file.translated_entries(), |
| 977 | - po_file.fuzzy_entries(), |
| 978 | - po_file.untranslated_entries()]: |
| 979 | - for entry in entry_group: |
| 980 | - if '{filename}' in entry.msgid: |
| 981 | - link_msgid = re.findall(link_regex, entry.msgid)[0] |
| 982 | - link_msgstr = list(re.findall(link_regex, entry.msgstr)) |
| 983 | - translated_doc = os.path.basename( |
| 984 | - self.documents.translated_doc( |
| 985 | - link_msgid, self)) |
| 986 | - if not link_msgstr: |
| 987 | - entry.msgstr = entry.msgid |
| 988 | - link_msgstr = [link_msgid] |
| 989 | - entry.msgstr = entry.msgstr.replace(link_msgstr[0], |
| 990 | - translated_doc) |
| 991 | - po_file.save(self.file_name) |
| 992 | + bcp47_code) |
| 993 | + |
| 994 | + def _call_po4a_translate(self, doc, po_fn, po4a): |
| 995 | + res = po4a.translate(doc, po_fn) |
| 996 | + return codecs.decode(res.communicate()[0]) |
| 997 | + |
| 998 | + def write_translated_markdown(self, po, po4a): |
| 999 | + for po_fn in po.langs: |
| 1000 | + for doc_fn in self.docs: |
| 1001 | + output = self._call_po4a_translate(doc_fn, po_fn, po4a) |
| 1002 | + title_line = output.split('\n')[0].split('Title: ')[1] |
| 1003 | + translated_title_line = po.find_translated_title_line( |
| 1004 | + title_line, po_fn) |
| 1005 | + output = '\n'.join([line for line in output.split('\n')][1:]) |
| 1006 | + new_path = self.translated_doc_fn(doc_fn, |
| 1007 | + po.langs[po_fn]['bcp47']) |
| 1008 | + text = "Title: %s\nDate:\n\n" % (translated_title_line) |
| 1009 | + text += output |
| 1010 | + if os.path.exists(new_path): |
| 1011 | + os.remove(new_path) |
| 1012 | + if not os.path.exists(os.path.dirname(new_path)): |
| 1013 | + os.makedirs(os.path.dirname(new_path)) |
| 1014 | + with open(new_path, 'w', encoding='utf-8') as f: |
| 1015 | + f.write(text) |
| 1016 | |
| 1017 | |
| 1018 | class Translations(object): |
| 1019 | def __init__(self): |
| 1020 | self._cleanup() |
| 1021 | - self.translations_dir = os.path.abspath(os.path.join(PATH, '../po')) |
| 1022 | - self.available_languages = [] |
| 1023 | self.documents = Documents() |
| 1024 | - for po_filename in glob.glob(self.translations_dir+'/*.po'): |
| 1025 | - self.available_languages += [Language(po_filename, self.documents)] |
| 1026 | - self.fake_lang_code = 'en_US' |
| 1027 | - self.fake_po_file = os.path.join(self.translations_dir, |
| 1028 | - '%s.po' % self.fake_lang_code) |
| 1029 | - self.pot_file = os.path.join(self.translations_dir, |
| 1030 | - "help.pot") |
| 1031 | - self.po4a = PO4A(self.pot_file) |
| 1032 | - |
| 1033 | - def __del__(self): |
| 1034 | - if os.path.exists(self.fake_po_file): |
| 1035 | - os.remove(self.fake_po_file) |
| 1036 | + self.po4a = PO4A() |
| 1037 | + self.po = PO(self.po4a) |
| 1038 | |
| 1039 | def _cleanup(self): |
| 1040 | r = subprocess.Popen(['bzr', 'ignored'], stdout=subprocess.PIPE) |
| 1041 | - files = [os.path.join(PATH, '../..', f.split(' ')[0]) |
| 1042 | - for f in codecs.decode(r.communicate()[0]).split('\n') |
| 1043 | - if f.strip() != ''] |
| 1044 | - files = [f for f in files if os.path.exists(f)] |
| 1045 | - for f in files: |
| 1046 | + fns = [os.path.join(PATH, '../..', f.split(' ')[0]) |
| 1047 | + for f in codecs.decode(r.communicate()[0]).split('\n') |
| 1048 | + if f.strip() != ''] |
| 1049 | + fns = [f for f in fns if os.path.exists(f)] |
| 1050 | + for f in fns: |
| 1051 | try: |
| 1052 | shutil.rmtree(f) |
| 1053 | except NotADirectoryError: |
| 1054 | os.remove(f) |
| 1055 | |
| 1056 | def generate_pot_file(self): |
| 1057 | - return self.po4a.gettextize(self.documents.docs) |
| 1058 | - |
| 1059 | - def update_po_files(self): |
| 1060 | - return self.po4a.updatepo(self.available_languages, |
| 1061 | - self.documents.docs) |
| 1062 | - |
| 1063 | - def rewrite_links(self): |
| 1064 | - self._generate_fake_pofile() |
| 1065 | - for lang in self.available_languages: |
| 1066 | - lang.rewrite_links() |
| 1067 | - |
| 1068 | - # we generate a fake translation for en-US which is going to be |
| 1069 | - # the default |
| 1070 | - def _generate_fake_pofile(self): |
| 1071 | - if os.path.exists(self.fake_po_file): |
| 1072 | - os.remove(self.fake_po_file) |
| 1073 | - shutil.copy(self.pot_file, self.fake_po_file) |
| 1074 | - self.available_languages += [Language(self.fake_po_file, |
| 1075 | - self.documents)] |
| 1076 | + return self.po.generate_pot_file(self.documents) |
| 1077 | |
| 1078 | def generate_translations(self): |
| 1079 | - for lang in self.available_languages: |
| 1080 | - self.documents.write_translated_markdown(lang, self.po4a) |
| 1081 | + self.po.generate_fake_pofile() |
| 1082 | + self.po.rewrite_links(self.documents) |
| 1083 | + self.documents.write_translated_markdown(self.po, self.po4a) |
Looks good to me, just two inline comments.