Merge lp:~malizor/launchpad/fixes-bug-608631 into lp:launchpad

Proposed by Nicolas Delvaux
Status: Merged
Approved by: Данило Шеган
Approved revision: no longer in the source branch.
Merged at revision: 11781
Proposed branch: lp:~malizor/launchpad/fixes-bug-608631
Merge into: lp:launchpad
Diff against target: 160 lines (+52/-15)
3 files modified
lib/lp/translations/browser/browser_helpers.py (+7/-2)
lib/lp/translations/doc/browser-helpers.txt (+42/-11)
lib/lp/translations/interfaces/translations.py (+3/-2)
To merge this branch: bzr merge lp:~malizor/launchpad/fixes-bug-608631
Reviewer Review Type Date Requested Status
Данило Шеган (community) Approve
Gavin Panella (community) Approve
Review via email: mp+37996@code.launchpad.net

This proposal supersedes a proposal from 2010-10-01.

Commit message

Users now can use the [nnbsp] tag to input a narrow no-break space in Rosetta. This tag representation is also a workaround for some Browsers (eg. in Rekonq NNBSP is displayed as a zero-width character).

Description of the change

== Summary ==

Bug 608631 describe the fact that there is no easy way to input and to display narrow no-break spaces (U+202F) in Rosetta.
Narrow no-break spaces are mainly used in French before ";:!?»" chars and after "«", but they are also used in some other languages (e.g. for the short form of the Czech dates and others).

Input of NNBSP is a problem for example on MS Windows (users need to mess around in the registry) and on GNU/Linux if your keyboard layout does not provide a shortcut for it.

Display of NNBSP is a problem in some browsers.
All versions of MS Internet Explorer *on Windows XP* display a square instead of the regular character (it works on Vista and Seven, here the bug lays in the OS build-in text renderer). There is also a bug in Qt which means that Qt browsers (Konqueror, Rekonq...) display NNBSP as a 0 width char.
Basically, it displays well on Firefox, GTK based browsers (Epiphany, Midori...) and on IE (on Vista and Seven).

On top of that, it is sometime difficult to tell apart NNBSP from a white space or a no-break space. So, a helper to recognize NNBSP is necessary anyway.

== Proposed fix ==

As discussed with Данило Шеган, it seems that implementing a new tag (as already existing [tab] and [nbsp]) is the best answer to this.

== Pre-implementation notes ==

The obvious tag for NNBSP is [nnbsp], even if it may be too close to [nbsp], we agreed that this is the best solution.
(I talked about it on the ubuntu-l10n-fr mailing-list)

== Implementation details ==

Implementation was quite easy with the existing code for other tags.
There is no really new code, so this should not cause anything to break (that wouldn't have broke without this patch I mean ;-)).

== Test ==

bin/test -cvv -m lp.translations -t browser-helpers.txt

== Demo and Q/A ==

To demo and Q/A this change, do the following:

- Log on as Sample Person (<email address hidden>:test)
- Visit any translation page (e.g. https://translations.launchpad.dev/evolution/trunk/+pots/evolution-2.2-test/es/+translate )
- Input something like "Test[nnbsp]!" and/or it's escaped version "Test\[nnbsp]!" and/or the 'literal' version "Test !"
- Save your translation(s) and see the results (better here with the above example: https://translations.launchpad.dev/evolution/trunk/+pots/evolution-2.2-test/es/+filter?person=name12 )

== Launchpad lint ==

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/translations/browser/browser_helpers.py
  lib/lp/translations/doc/browser-helpers.txt
  lib/lp/translations/interfaces/translations.py

I fixed all warnings in these files (most of them where not related to my code)

To post a comment you must log in.
Revision history for this message
Данило Шеган (danilo) wrote : Posted in a previous version of this proposal

The change looks good. I am still very unhappy with the use of [nbthin]. How about we use [nnbsp] (I know why you hate it, but I find it's better than [nbthin], and others I talked to agree).

review: Needs Fixing
Revision history for this message
Nicolas Delvaux (malizor) wrote : Posted in a previous version of this proposal

I raised the issue on ubuntu-l10n-fr and lp-l10n-fr.
We will see if someone propose something better and/or if I'm the only one that fear confusion between [nbsp] and [nnbsp].

Otherwise, I also prefer [nbthin] because the French for NNBSP is "espace fine insécable" which literally (word for word) translate to "no-break thin space".

Revision history for this message
Nicolas Delvaux (malizor) wrote : Posted in a previous version of this proposal

The tag is now [nnbsp].
I talked about it on the ubuntu-l10n-fr mailing-list and they feel that there may not be too much confusion between [nnbsp] and [nbsp].
And NNBSP is the acronym for narrow no-break space, so [nnbsp] is simply more logical.

Revision history for this message
Gavin Panella (allenap) :
review: Approve
Revision history for this message
Данило Шеган (danilo) wrote :

Good to land.

Nicolas, thanks for working on this. Once it lands this MP will be marked as 'Merged' and soon after bug will be marked as 'Fix committed' and tagged with 'qa-needstesting'. That will mean that you can go to "edge" (i.e. just use "translations.edge.launchpad.net" as the domain instead of "translations.launchpad.net" for any regular LP web page you want to try this on) and try this new feature out. Once you can confirm it works, you can tag the bug with 'qa-ok' (and remove the qa-needstesting tag at the same time).

review: Approve
Revision history for this message
Gavin Panella (allenap) wrote :

Nicolas, one more thing before I merge this: can you set a commit message?

Please follow the guide at https://dev.launchpad.net/PQMCommitMessages. You only need to enter the descriptive part. Don't worry about the leading parts in square [] braces; they are calculated automatically.

Revision history for this message
Nicolas Delvaux (malizor) wrote :

Done.

Revision history for this message
Данило Шеган (danilo) wrote :

Unfortunately, due to changes happening with our infrastructure, QA needed to be done on "qastaging" and not on "edge" as I suggested: sorry about the confusion. To speed deployment up, I did it this time around.

Revision history for this message
Nicolas Delvaux (malizor) wrote :

Ok, thank you.
I also confirm that it works on qastaging.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/translations/browser/browser_helpers.py'
2--- lib/lp/translations/browser/browser_helpers.py 2010-08-20 20:31:18 +0000
3+++ lib/lp/translations/browser/browser_helpers.py 2010-10-08 17:24:20 +0000
4@@ -31,7 +31,9 @@
5 return helpers.text_replaced(text, {'[tab]': '\t',
6 r'\[tab]': '[tab]',
7 '[nbsp]': u'\u00a0',
8- r'\[nbsp]': '[nbsp]'})
9+ r'\[nbsp]': '[nbsp]',
10+ '[nnbsp]': u'\u202f',
11+ r'\[nnbsp]': '[nnbsp]'})
12
13
14 def expand_rosetta_escapes(unicode_text):
15@@ -39,7 +41,10 @@
16 escapes = {u'\t': TranslationConstants.TAB_CHAR,
17 u'[tab]': TranslationConstants.TAB_CHAR_ESCAPED,
18 u'\u00a0': TranslationConstants.NO_BREAK_SPACE_CHAR,
19- u'[nbsp]': TranslationConstants.NO_BREAK_SPACE_CHAR_ESCAPED}
20+ u'[nbsp]': TranslationConstants.NO_BREAK_SPACE_CHAR_ESCAPED,
21+ u'\u202f': TranslationConstants.NARROW_NO_BREAK_SPACE_CHAR,
22+ u'[nnbsp]':
23+ TranslationConstants.NARROW_NO_BREAK_SPACE_CHAR_ESCAPED}
24 return helpers.text_replaced(unicode_text, escapes)
25
26
27
28=== modified file 'lib/lp/translations/doc/browser-helpers.txt'
29--- lib/lp/translations/doc/browser-helpers.txt 2009-09-07 07:25:18 +0000
30+++ lib/lp/translations/doc/browser-helpers.txt 2010-10-08 17:24:20 +0000
31@@ -1,9 +1,11 @@
32-= Translation message helper functions =
33+Translation message helper functions
34+====================================
35
36 For rendering translations in the TranslationMessageView a number of
37 helper functions exist. The following sections cover them in detail.
38
39-== contract_rosetta_escapes ==
40+contract_rosetta_escapes
41+------------------------
42
43 >>> from lp.translations.browser.browser_helpers import (
44 ... contract_rosetta_escapes)
45@@ -45,8 +47,20 @@
46 >>> contract_rosetta_escapes('foo\\[nbsp]bar')
47 'foo[nbsp]bar'
48
49-
50-== expand_rosetta_escapes ==
51+Similarly, string '[nnbsp]' gets converted to narrow no-break space
52+character.
53+
54+ >>> contract_rosetta_escapes('foo[nnbsp]bar')
55+ u'foo\u202fbar'
56+
57+The string '\[nnbsp]' gets converted to a literal '[nnbsp]'.
58+
59+ >>> contract_rosetta_escapes('foo\\[nnbsp]bar')
60+ 'foo[nnbsp]bar'
61+
62+
63+expand_rosetta_escapes
64+----------------------
65
66 >>> from lp.translations.browser.browser_helpers import (
67 ... expand_rosetta_escapes)
68@@ -93,8 +107,22 @@
69 >>> expand_rosetta_escapes(u'foo[nbsp]bar')
70 u'foo<code>\\[nbsp]</code>bar'
71
72-
73-== parse_cformat_string ==
74+Similarly, narrow no-break spaces get converted to a special constant
75+TranslationConstants.NARROW_NO_BREAK_SPACE_CHAR which renders as below:
76+
77+ >>> expand_rosetta_escapes(u'foo\u202fbar')
78+ u'foo<code>[nnbsp]</code>bar'
79+
80+Literal occurrences of u'[nnbsp]' get escaped to a special constant
81+TranslationConstants.NARROW_NO_BREAK_SPACE_CHAR_ESCAPED which renders them
82+as below:
83+
84+ >>> expand_rosetta_escapes(u'foo[nnbsp]bar')
85+ u'foo<code>\\[nnbsp]</code>bar'
86+
87+
88+parse_cformat_string
89+--------------------
90
91 >>> from lp.translations.browser.browser_helpers import (
92 ... parse_cformat_string)
93@@ -112,7 +140,8 @@
94 UnrecognisedCFormatString: %
95
96
97-== text_to_html ==
98+text_to_html
99+------------
100
101 >>> from lp.translations.browser.browser_helpers import (
102 ... text_to_html)
103@@ -178,7 +207,8 @@
104 u'foo<img alt="" src="/@@/translation-newline" /><br/>\nbar'
105
106
107-== convert_newlines_to_web_form ==
108+convert_newlines_to_web_form
109+----------------------------
110
111 >>> from lp.translations.browser.browser_helpers import (
112 ... convert_newlines_to_web_form)
113@@ -194,7 +224,8 @@
114 u'foo\r\nbar'
115
116
117-== count_lines ==
118+count_lines
119+-----------
120
121 >>> from lp.translations.browser.browser_helpers import count_lines
122 >>> count_lines("foo")
123@@ -216,8 +247,8 @@
124 ... "1234566789a123456789a")
125 2
126 >>> count_lines(
127- ... "123456789abc123456789abc123456789abc123456789abc123456789abc123456\n"
128- ... "789a123456789a123456789a")
129+ ... "123456789abc123456789abc123456789abc123456789abc123456789abc"
130+ ... "123456\n789a123456789a123456789a")
131 3
132 >>> count_lines(
133 ... "123456789abc123456789abc123456789abc123456789abc123456789abc"
134
135=== modified file 'lib/lp/translations/interfaces/translations.py'
136--- lib/lp/translations/interfaces/translations.py 2010-08-20 20:31:18 +0000
137+++ lib/lp/translations/interfaces/translations.py 2010-10-08 17:24:20 +0000
138@@ -16,6 +16,7 @@
139 'TranslationsBranchImportMode',
140 )
141
142+
143 class TranslationConstants:
144 """Set of constants used inside the context of translations."""
145
146@@ -31,6 +32,8 @@
147 TAB_CHAR_ESCAPED = '<code>' + r'\[tab]' + '</code>'
148 NO_BREAK_SPACE_CHAR = '<code>[nbsp]</code>'
149 NO_BREAK_SPACE_CHAR_ESCAPED = '<code>' + r'\[nbsp]' + '</code>'
150+ NARROW_NO_BREAK_SPACE_CHAR = '<code>[nnbsp]</code>'
151+ NARROW_NO_BREAK_SPACE_CHAR_ESCAPED = '<code>' + r'\[nnbsp]' + '</code>'
152
153
154 class TranslationsBranchImportMode(DBEnumeratedType):
155@@ -54,5 +57,3 @@
156 Import all translation files (templates and translations)
157 found in the branch.
158 """)
159-
160-