From kde-i18n-doc Sat Aug 30 16:49:54 2008 From: Thomas Reitelbach Date: Sat, 30 Aug 2008 16:49:54 +0000 To: kde-i18n-doc Subject: Re: Scripting the fuzzy clock translation Message-Id: <200808301849.55756.tr () erdfunkstelle ! de> X-MARC-Message: https://marc.info/?l=kde-i18n-doc&m=122011511315833 Am Donnerstag 17 Juli 2008 22:30:19 schrieb Chusslove Illich: > > [: Thomas Reitelbach :] > > [...] to script a few string in the fuzzy clock [...] If for example %1 > > returns "5", then in realiy I have to show "6" to the user. [...] can > > someone please give me some help? > > Why certainly -- I had the exact same need, show +1 to the user, hence same > solution is applicable. Hello Chusslove, sorry for the late answer, but I wanted to thank you for this cool scripted solution for the fuzzy clock! It works like a charm :-))) Cheers Thomas > First you need to create the file de/scripts/kdelibs/kdelibs4/kdelibs4.js > (yes, that's kdelibs4 mentioned twice in the path) and put into it the code > snippet given here: > http://techbase.kde.org/index.php?title=Localization/Concepts/Transcript#Au >tomatic_Property_Calls -- except that in the last non-comment line instead > of "properties" I'd put "Eigenschaften" :) To install the script rerun > scripts/autogen.sh de and install the language module as usual. > > Second part is in the fuzzy clock's PO: > > msgctxt "hour in the messages below" > msgid "one" > msgstr "" > "eins" > "|/|" > "$[Eigenschaften nach zwei]" > > ... > > msgctxt "hour in the messages below" > msgid "twelve" > msgstr "" > "zwölf" > "|/|" > "$[Eigenschaften nach eins]" > > ... > > msgctxt "%1 the hour translated above" > msgid "half past %1" > msgstr "" > "%1 und dreizig" > "|/|" > "halb $[nach %1]" > > And that's about it. > > Some explanations: > > The setMsgstrProps props function in the kdelibs4.js is a general property- > setter for any msgstr field; in the example above, I made it available in > POs as Eigenschaften (German for "properties") scripting call. Thus, > $[Eigenschaften nach zwei] tells that the ordinary part of that msgstr, > "eins" (one), has the property "nach" (after) which is "zwei" (two). > > The property-setter makes these properties into new scripting calls. So in > the message "half past %1", which needs hour + 1 in German, the "nach" call > can be used to retrieve the next hour, set by that property for given %1, > and insert it into msgstr: "halb $[nach %1]". The non-scripted part of that > message, "%1 und dreizig", is used only if something goes horribly wrong > and the script fails.