Opened 10 years ago

Closed 9 years ago

#8175 closed defect (fixed)

Themestrings which contains a newline character are untranslatable

Reported by: Kenni Lund <kenni@…> Owned by: stuartm
Priority: minor Milestone: 0.24
Component: MythTV - User Interface Library Version: head
Severity: medium Keywords:
Cc: Ticket locked: no

Description

All themestring which contains the newline-character (\n) are translatable by linguist, but they are never used by mythfrontend or the plugins. I haven't been able to figure out where the exact problem is, but the following themes and strings are affected:

[kenni@ION trunk]$ grep -r -e "\\\n" myththemes/ mythtv/|grep "<value>" |grep ".xml:"
myththemes/Graphite/schedule-ui.xml:            <value>You Haven't Scheduled Any Programs To Be Recorded\n
myththemes/Mythbuntu/schedule-ui.xml:            <value>You Haven't Scheduled Any Programs To Be Recorded\n
myththemes/Mythbuntu/schedule-ui.xml:            <value>You Haven't Scheduled Any Programs To Be Recorded\n
myththemes/Arclight/weather-ui.xml:            <value>This screen governs the behavior of the weather screens.  You can enable a background weather update which will run regardless of being on the weather screen, and configure how many seconds each screen will display.\n\nWhen you are done configuring the Weather Plugin, click "Finish" to continue.</value>
myththemes/Arclight/weather-ui.xml:            <value>This settings screen governs the behavior of individual weather scripts.  Select the script whose behavior you with to change and press the right arrow. Adjust the interval at which data is retrieved, and the timeout for accessing the site.\n\nWhen you have completed your changes, click "Finish" to continue.</value>
myththemes/Arclight/browser-ui.xml:            <value>You can edit the name, URL, and category for the selected Web Site on this screen.\n\nWhen you have finished editing, select "OK" or "Cancel" to continue.</value>
myththemes/Arclight/news-ui.xml:            <value>You can edit the name, URL, and icon path for the selected RSS Feed on this screen.  You can also designate the item as a podcast.\n\nWhen you have finished editing, select "OK" or "Cancel" to continue.</value>
myththemes/Arclight/schedule-ui.xml:            <value>Sort By:\n(1) Title (2) Priority (4) Type</value>
myththemes/Arclight/schedule-ui.xml:            <value>To create a custom priority rule, enter a name and priority adjustment.  You can them select from existing priority templates or create one of your own using SQL syntax in the "Clause SQL" edit box.\n\nOnce you have completed your rule, can can Test, Delete, or Install it right away.</value>
myththemes/Arclight/schedule-ui.xml:            <value>You can specify basic criteria to create powerful search and record rules.  Below, you may enter title, subtitle, and description phrases (all optional), as well as category, genre, and channel values to refine a complex search for programs.\n\nWhen you have completed your configuration, press "OK" to search.</value>
myththemes/Arclight/schedule-ui.xml:            <value>Sort By:\n(1) Title (2) Priority (4) Type</value>
myththemes/Arclight/schedule-ui.xml:            <value>To create a custom recording rule, either select an existing rule, or create a new rule by typing in a name.  Then select a rule type and hit enter.  The SQL code will be transferred below, and you can edit it and insert your own program information.\n\nFinally, you can test, immediately activate, store, or cancel your rule.</value>
myththemes/Arclight/recordings-ui.xml:            <value>Using the text areas below, you can change the recording title, subtitle, and description.\n\nOnce you have completed your modifications, click the "OK" button.</value>
myththemes/Arclight/video-ui.xml:            <value>On this screen, you can add new extensions to be recognized by the Video Plugin.  If a scan does not add your files, create a new extension below by clicking the "New" button.\n\nIf you select "Use Default Player," the player command set for the extension will be ignored.  "Ignore This File Type" prevents the items from appearing in a scan.</value>
myththemes/Arclight/netvision-ui.xml:            <value>Type the URL to an RSS 2.0 media feed below.  If editing an existing feed, modify any of the values you like.  Press "Save" to save/subscribe.\n\nFor new subscriptions, you can simply enter the URL and click "Save."</value>
myththemes/metallurgy/schedule-ui.xml:            <value>You Haven't Scheduled Any Programs To Be Recorded\n
mythtv/themes/default-wide/schedule-ui.xml:            <value>You Haven't Scheduled Any Programs To Be Recorded\n
mythtv/themes/default-wide/schedule-ui.xml:            <value>You Haven't Scheduled Any Programs To Be Recorded\n
mythtv/themes/Terra/schedule-ui.xml:            <value>You Haven't Scheduled Any Programs To Be Recorded\n
mythtv/themes/Terra/schedule-ui.xml:            <value>You Haven't Scheduled Any Programs To Be Recorded\n
mythtv/themes/MythCenter-wide/schedule-ui.xml:            <value>You Haven't Scheduled Any Programs To Be Recorded\n
mythtv/themes/MythCenter-wide/schedule-ui.xml:            <value>You Haven't Scheduled Any Programs To Be Recorded\n
mythtv/themes/MythCenter/schedule-ui.xml:            <value>You Haven't Scheduled Any Programs To Be Recorded\n
mythtv/themes/MythCenter/schedule-ui.xml:            <value>You Haven't Scheduled Any Programs To Be Recorded\n
mythtv/themes/default/schedule-ui.xml:            <value>You Haven't Scheduled Any Programs To Be Recorded\n
mythtv/themes/default/schedule-ui.xml:            <value>You Haven't Scheduled Any Programs To Be Recorded\n

This has been tested with the Danish translation and r23735.

Attachments (2)

themeuilatest.tgz (2.1 KB) - added by Nicolas Riendeau <knight@…> 10 years ago.
themeuilatest.diff (9.7 KB) - added by stuartm 10 years ago.
Uncompressed patch

Download all attachments as: .zip

Change History (8)

comment:1 Changed 10 years ago by Nicolas Riendeau <knight@…>

Considering I told you about this problem on the dev mailing list you could at least have let me open the ticket if I was unable to fix it.

I knew what the problem was with your whitespaces issues and did not tell you outright what it was (at least not until you mentioned not finding other whitespaces issues).

devs, I have no intention of discussing this further on Trac so you don't need to lock this ticket.

Sorry for the noise...

Nick

comment:2 Changed 10 years ago by Nicolas Riendeau <knight@…>

Hi,

I am attaching to this ticket a fix for the above-mentioned problem.

The problem was, essentially, that the strings extracted by themestring/themestringstool and then imported with lupdate are slightly reformatted to in the process (\n is converted to a real newline and the non-significant spaces caused by the XML formatting are removed) and when Qt tries to look them up it doesn't find them.

What this patch does is essentially reformat the text looked up in the same way themestring/themestringtool does it so that the translated text can actually be found.

The patch has been tested with the Danish translation by Kenni Lund (of the Danish translation) and with the French translation by Gilles and me (of the French language translation team). A big thanks to Gilles and Kenni for their help! It has also been tested with the English "translation" to make sure it did not have any adverse effect.

The problem was initially reported (to me) by Gilles.

Thank you!

Nick

Changed 10 years ago by Nicolas Riendeau <knight@…>

Attachment: themeuilatest.tgz added

comment:3 Changed 10 years ago by robertm

Component: TranslationsMythTV - User Interface Library
Owner: changed from Reynaldo H. Verdejo Pinochet to stuartm
Status: newassigned

Changed 10 years ago by stuartm

Attachment: themeuilatest.diff added

Uncompressed patch

comment:4 Changed 10 years ago by stuartm

Milestone: unknown0.24
Status: assignedaccepted

I think I'm going to fix this in themestringtools instead, it means breaking a few existing translations but it's less invasive and means no performance hit each time we load a screen.

comment:5 Changed 10 years ago by Nicolas Riendeau <knight@…>

Hi,

If you can find someway to do it in themestringtool than I agree that it would indeed be preferable than to do this sort of string manipulation at runtime.

The \n gets remapped to a real newline by lupdate (which believe \n in source code should be remapped to a real newline) and the fix for this seems easy enough, add a second backslash before the other one in themestringtool so that the .ts file ends up not having real newlines but \n instead.

The con with this though is that it certainly won't look as good in Qt linguist (or in a text editor) as the formatting will not clearly show the line change.

The biggest problem is not there however, it's with the non-significant spaces added by the XML formatting.

The only way I could think of this problem could be addressed is by imposing restrictions to the themers.

There are currently strings in some themes which look like this:

This is a test string that is split on many lines and which contains a lot of non-significant spaces which should be removed before trying to display it. The newlines in that string should be removed as well because they are only there to format this text nicely in the XML theme file.

The following code (in themestringtool and in my patch) takes care of this by removing all these extraneous spaces:

Remove newline whitespace added by xml formatting QStringList lines = text.split('\n'); QStringList::iterator lineIt;

for (lineIt = lines.begin(); lineIt != lines.end(); ++lineIt) {

(*lineIt) = (*lineIt).trimmed();

}

text = lines.join(" ");

I can't see a way to address this problem anywhere else than at runtime or remove support for this from themestringtool, modify the themes and tell the themers to stop formatting text this way.

I said the patch did not have any "adverse" effect on the English "translation" but it did have an effect on it. It actually has a positive effect on strings formatted that way which are currently not formatted correctly, in English, because of all these non-significant spaces.

Have a nice day!

Nick

comment:6 Changed 9 years ago by stuartm

Resolution: fixed
Status: acceptedclosed

(In [26053]) Fix the translation of theme strings containing newline characters. Based on patch from Nicolas Riendeau. Fixes #8175

Note: See TracTickets for help on using tickets.