diff options
author | Caolán McNamara <caolanm@redhat.com> | 2021-01-05 14:58:40 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2021-01-15 10:11:43 +0100 |
commit | d5d905b480c2a9b1db982f2867e87b5c230d1ab9 (patch) | |
tree | 7cdda2d3435ebe6367f2e7becafa48c7f369b501 /l10ntools | |
parent | f89b94c280e8d986cdf08271f5cdc6b1dfe09575 (diff) |
prep to replace stock button labels
a) as per https://developer.gnome.org/gtk3/stable/gtk3-Stock-Items.html
use-stock=gtk-ok is deprecated and plain "OK", "Cancel" are indicated
instead.
b) to avoid adding thousands of extra labels to translate we'll convert
use-stock buttons to use the translatable strings, but give them all the
same "stock" translation context. Our translation rules don't like
duplicates in the output .po's so strip "stock" contents from the
translation collection rules in uiex and add a single set per .po in
l10ntools/source/localize.cxx
c) a script to rewrite the .uis to the new rules
the previously use-stock labels won't appear translated until there has
been a round trip of extraction, translations and import of translations
Change-Id: Ibe4d0d27f2abbf5aa3df9c63af1561cd01d9fddd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108812
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'l10ntools')
-rw-r--r-- | l10ntools/source/localize.cxx | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/l10ntools/source/localize.cxx b/l10ntools/source/localize.cxx index 9b1ac7f14308..3cb8c8df2657 100644 --- a/l10ntools/source/localize.cxx +++ b/l10ntools/source/localize.cxx @@ -213,13 +213,18 @@ bool handleFile(const OString& rProject, const OUString& rUrl, const OString& rP sInPath = OUStringToOString( sInPathTmp, RTL_TEXTENCODING_UTF8 ); } OString sOutPath; - if (commands[i].executable == "uiex" || commands[i].executable == "hrcex") + bool bCreatedFile = false; + bool bSimpleModuleCase = commands[i].executable == "uiex" || commands[i].executable == "hrcex"; + if (bSimpleModuleCase) sOutPath = gDestRoot + "/" + rProject + "/messages.pot"; else sOutPath = rPotDir + ".pot"; if (!fileExists(sOutPath)) + { InitPoFile(rProject, sInPath, rPotDir, sOutPath); + bCreatedFile = true; + } handleCommand(sInPath, sOutPath, commands[i].executable); { @@ -229,6 +234,7 @@ bool handleFile(const OString& rProject, const OUString& rUrl, const OString& rP aPOStream.readEntry( aPO ); bool bDel = aPOStream.eof(); aPOStream.close(); + if (bDel) { if ( system(OString("rm " + sOutPath).getStr()) != 0 ) @@ -239,8 +245,33 @@ bool handleFile(const OString& rProject, const OUString& rUrl, const OString& rP throw false; //TODO } } + else if (bCreatedFile && bSimpleModuleCase) + { + // add one stock Add, Cancel, Close, Help, No, OK, Yes entry to each module.po + // and duplicates in .ui files then filtered out by solenv/bin/uiex + + std::ofstream aOutPut; + aOutPut.open(sOutPath.getStr(), std::ios_base::out | std::ios_base::app); + + aOutPut << "#. wH3TZ\nmsgctxt \"stock\"\nmsgid \"_Add\"\nmsgstr \"\"\n\n"; + aOutPut << "#. S9dsC\nmsgctxt \"stock\"\nmsgid \"_Apply\"\nmsgstr \"\"\n\n"; + aOutPut << "#. TMo6G\nmsgctxt \"stock\"\nmsgid \"_Cancel\"\nmsgstr \"\"\n\n"; + aOutPut << "#. MRCkv\nmsgctxt \"stock\"\nmsgid \"_Close\"\nmsgstr \"\"\n\n"; + aOutPut << "#. nvx5t\nmsgctxt \"stock\"\nmsgid \"_Delete\"\nmsgstr \"\"\n\n"; + aOutPut << "#. YspCj\nmsgctxt \"stock\"\nmsgid \"_Edit\"\nmsgstr \"\"\n\n"; + aOutPut << "#. imQxr\nmsgctxt \"stock\"\nmsgid \"_Help\"\nmsgstr \"\"\n\n"; + aOutPut << "#. RbjyB\nmsgctxt \"stock\"\nmsgid \"_New\"\nmsgstr \"\"\n\n"; + aOutPut << "#. dx2yy\nmsgctxt \"stock\"\nmsgid \"_No\"\nmsgstr \"\"\n\n"; + aOutPut << "#. M9DsL\nmsgctxt \"stock\"\nmsgid \"_OK\"\nmsgstr \"\"\n\n"; + aOutPut << "#. VtJS9\nmsgctxt \"stock\"\nmsgid \"_Remove\"\nmsgstr \"\"\n\n"; + aOutPut << "#. C69Fy\nmsgctxt \"stock\"\nmsgid \"_Reset\"\nmsgstr \"\"\n\n"; + aOutPut << "#. mgpxh\nmsgctxt \"stock\"\nmsgid \"_Yes\"\nmsgstr \"\"\n"; + + aOutPut.close(); + } } + return true; } break; |