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

Proposed by Nicolas Delvaux
Status: Superseded
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) Needs Fixing
Review via email: mp+37287@code.launchpad.net

This proposal has been superseded by a proposal from 2010-10-08.

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 :

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 :

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 :

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.

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:02:58 +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:02:58 +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:02:58 +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-