[kcm] Fix i18n output file name and split texts
ClosedPublic

Authored by romangg on Sep 8 2019, 8:26 AM.

Details

Summary

The output file name must be kcm_kscreen.po for translators to pick it up and
text being split to respect the 100 chars line limit must first be translated
before being merged together again.

Test Plan

KCM starts without errors.

Diff Detail

Repository
R104 KScreen
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
romangg created this revision.Sep 8 2019, 8:26 AM
Restricted Application added a project: Plasma. · View Herald TranscriptSep 8 2019, 8:26 AM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
romangg requested review of this revision.Sep 8 2019, 8:26 AM
yurchor accepted this revision.Sep 8 2019, 8:28 AM

Thanks.

This revision is now accepted and ready to land.Sep 8 2019, 8:28 AM
This revision was automatically updated to reflect the committed changes.
pino added a subscriber: pino.Sep 8 2019, 8:35 AM

Please do not split the messages just for sake of column width.

What about just removing the + to concatenate the strings, and just use normal continuation, i.e.:

text: i18n("Are you sure you want to disable all outputs? "
           "This might render the device unusable.")
In D23783#527562, @pino wrote:

Please do not split the messages just for sake of column width.

If there is a better solution than splitting text with a + while still respecting the line chars limit I will upload a new patch.

What about just removing the + to concatenate the strings, and just use normal continuation, i.e.:

text: i18n("Are you sure you want to disable all outputs? "
           "This might render the device unusable.")

This sadly didn't work. The KCM just doesn't start then with an error message. Does the macro need to be improved to support this?

pino added a comment.Sep 8 2019, 8:47 AM
In D23783#527562, @pino wrote:

Please do not split the messages just for sake of column width.

If there is a better solution than splitting text with a + while still respecting the line chars limit I will upload a new patch.

Even reading the other RR, I still do not understand how this 100 chars limit is so important, even to make i18n worse.

What about just removing the + to concatenate the strings, and just use normal continuation, i.e.:

text: i18n("Are you sure you want to disable all outputs? "
           "This might render the device unusable.")

This sadly didn't work. The KCM just doesn't start then with an error message. Does the macro need to be improved to support this?

Which macro?

In D23783#527579, @pino wrote:

Which macro?

i18n(...) or "function"?

pino added a comment.Sep 8 2019, 8:49 AM
In D23783#527579, @pino wrote:

Which macro?

i18n(...) or "function"?

It's a normal QML function ...

diff --git a/kcm/package/contents/ui/main.qml b/kcm/package/contents/ui/main.qml
index 2e61aa5..191daf3 100644
--- a/kcm/package/contents/ui/main.qml
+++ b/kcm/package/contents/ui/main.qml
@@ -41,8 +41,8 @@ KCM.SimpleKCM {
 
             Layout.fillWidth: true
             type: Kirigami.MessageType.Warning
-            text: i18n("Are you sure you want to disable all outputs? ") +
-                  i18n("This might render the device unusable.")
+            text: i18n("Are you sure you want to disable all outputs? \
+This might render the device unusable.")
             showCloseButton: true
 
             actions: [

This also works, but it's ugly because the second line has not the right indent.

pino added a comment.Sep 8 2019, 9:03 AM
diff --git a/kcm/package/contents/ui/main.qml b/kcm/package/contents/ui/main.qml
index 2e61aa5..191daf3 100644
--- a/kcm/package/contents/ui/main.qml
+++ b/kcm/package/contents/ui/main.qml
@@ -41,8 +41,8 @@ KCM.SimpleKCM {
 
             Layout.fillWidth: true
             type: Kirigami.MessageType.Warning
-            text: i18n("Are you sure you want to disable all outputs? ") +
-                  i18n("This might render the device unusable.")
+            text: i18n("Are you sure you want to disable all outputs? \
+This might render the device unusable.")
             showCloseButton: true
 
             actions: [

This also works, but it's ugly because the second line has not the right indent.

Pick your choice: this, or single-line messages. Either of them is way better than the currently committed hack.

This comment was removed by victorr.
zzag added a subscriber: zzag.Sep 8 2019, 9:32 AM
In D23783#527562, @pino wrote:

Please do not split the messages just for sake of column width.

What about just removing the + to concatenate the strings, and just use normal continuation, i.e.:

text: i18n("Are you sure you want to disable all outputs? "
           "This might render the device unusable.")

If I recall correctly, the grammar of ECMAScript doesn't allow such things.

romangg added a comment.EditedSep 8 2019, 1:31 PM
In D23783#527582, @pino wrote:

It's a normal QML function ...

If it's just a QML function why is it a problem to + some strings when providing them as an argument?

EDIT: I noticed there was an additional white space in the first version. Could this be the problem?

pino added a comment.Sep 8 2019, 1:55 PM
In D23783#527582, @pino wrote:

It's a normal QML function ...

If it's just a QML function why is it a problem to + some strings when providing them as an argument?

This is not a "problem" when translating the string at runtime, but rather when extracting it (with xgettext).
(x)gettext extracts only string literals, and a string concatenation is not (they are two strings, actually). This is why continuation lines do not pose issue: they are still a single literal string.

pino added a comment.Sep 8 2019, 3:06 PM

BTW: if by 2200 UTC none of the two solutions mentioned above (continuation lines, or single long lines) is implemented, I will revert the majority of a798e78d477e (leaving only the .pot renaming, which is correct).

@ltoscano The plus sign does not work.

This string:

text: i18n("Are you sure you want to disable all outputs? " +
           "This might render the device unusable.")

is extracted like Are you sure you want to disable all outputs?

pino added a comment.Sep 19 2019, 3:32 AM

@aspotashev: please read the discussion in this review request...

Need to add this patch.

Need to add this patch.

Need to fix the wrong -DTRANSLATION_DOMAIN