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
=== modified file 'lib/lp/translations/browser/browser_helpers.py'
--- lib/lp/translations/browser/browser_helpers.py 2010-08-20 20:31:18 +0000
+++ lib/lp/translations/browser/browser_helpers.py 2010-10-08 17:02:58 +0000
@@ -31,7 +31,9 @@
31 return helpers.text_replaced(text, {'[tab]': '\t',31 return helpers.text_replaced(text, {'[tab]': '\t',
32 r'\[tab]': '[tab]',32 r'\[tab]': '[tab]',
33 '[nbsp]': u'\u00a0',33 '[nbsp]': u'\u00a0',
34 r'\[nbsp]': '[nbsp]'})34 r'\[nbsp]': '[nbsp]',
35 '[nnbsp]': u'\u202f',
36 r'\[nnbsp]': '[nnbsp]'})
3537
3638
37def expand_rosetta_escapes(unicode_text):39def expand_rosetta_escapes(unicode_text):
@@ -39,7 +41,10 @@
39 escapes = {u'\t': TranslationConstants.TAB_CHAR,41 escapes = {u'\t': TranslationConstants.TAB_CHAR,
40 u'[tab]': TranslationConstants.TAB_CHAR_ESCAPED,42 u'[tab]': TranslationConstants.TAB_CHAR_ESCAPED,
41 u'\u00a0': TranslationConstants.NO_BREAK_SPACE_CHAR,43 u'\u00a0': TranslationConstants.NO_BREAK_SPACE_CHAR,
42 u'[nbsp]': TranslationConstants.NO_BREAK_SPACE_CHAR_ESCAPED}44 u'[nbsp]': TranslationConstants.NO_BREAK_SPACE_CHAR_ESCAPED,
45 u'\u202f': TranslationConstants.NARROW_NO_BREAK_SPACE_CHAR,
46 u'[nnbsp]':
47 TranslationConstants.NARROW_NO_BREAK_SPACE_CHAR_ESCAPED}
43 return helpers.text_replaced(unicode_text, escapes)48 return helpers.text_replaced(unicode_text, escapes)
4449
4550
4651
=== modified file 'lib/lp/translations/doc/browser-helpers.txt'
--- lib/lp/translations/doc/browser-helpers.txt 2009-09-07 07:25:18 +0000
+++ lib/lp/translations/doc/browser-helpers.txt 2010-10-08 17:02:58 +0000
@@ -1,9 +1,11 @@
1= Translation message helper functions =1Translation message helper functions
2====================================
23
3For rendering translations in the TranslationMessageView a number of4For rendering translations in the TranslationMessageView a number of
4helper functions exist. The following sections cover them in detail.5helper functions exist. The following sections cover them in detail.
56
6== contract_rosetta_escapes ==7contract_rosetta_escapes
8------------------------
79
8 >>> from lp.translations.browser.browser_helpers import (10 >>> from lp.translations.browser.browser_helpers import (
9 ... contract_rosetta_escapes)11 ... contract_rosetta_escapes)
@@ -45,8 +47,20 @@
45 >>> contract_rosetta_escapes('foo\\[nbsp]bar')47 >>> contract_rosetta_escapes('foo\\[nbsp]bar')
46 'foo[nbsp]bar'48 'foo[nbsp]bar'
4749
4850Similarly, string '[nnbsp]' gets converted to narrow no-break space
49== expand_rosetta_escapes ==51character.
52
53 >>> contract_rosetta_escapes('foo[nnbsp]bar')
54 u'foo\u202fbar'
55
56The string '\[nnbsp]' gets converted to a literal '[nnbsp]'.
57
58 >>> contract_rosetta_escapes('foo\\[nnbsp]bar')
59 'foo[nnbsp]bar'
60
61
62expand_rosetta_escapes
63----------------------
5064
51 >>> from lp.translations.browser.browser_helpers import (65 >>> from lp.translations.browser.browser_helpers import (
52 ... expand_rosetta_escapes)66 ... expand_rosetta_escapes)
@@ -93,8 +107,22 @@
93 >>> expand_rosetta_escapes(u'foo[nbsp]bar')107 >>> expand_rosetta_escapes(u'foo[nbsp]bar')
94 u'foo<code>\\[nbsp]</code>bar'108 u'foo<code>\\[nbsp]</code>bar'
95109
96110Similarly, narrow no-break spaces get converted to a special constant
97== parse_cformat_string ==111TranslationConstants.NARROW_NO_BREAK_SPACE_CHAR which renders as below:
112
113 >>> expand_rosetta_escapes(u'foo\u202fbar')
114 u'foo<code>[nnbsp]</code>bar'
115
116Literal occurrences of u'[nnbsp]' get escaped to a special constant
117TranslationConstants.NARROW_NO_BREAK_SPACE_CHAR_ESCAPED which renders them
118as below:
119
120 >>> expand_rosetta_escapes(u'foo[nnbsp]bar')
121 u'foo<code>\\[nnbsp]</code>bar'
122
123
124parse_cformat_string
125--------------------
98126
99 >>> from lp.translations.browser.browser_helpers import (127 >>> from lp.translations.browser.browser_helpers import (
100 ... parse_cformat_string)128 ... parse_cformat_string)
@@ -112,7 +140,8 @@
112 UnrecognisedCFormatString: %140 UnrecognisedCFormatString: %
113141
114142
115== text_to_html ==143text_to_html
144------------
116145
117 >>> from lp.translations.browser.browser_helpers import (146 >>> from lp.translations.browser.browser_helpers import (
118 ... text_to_html)147 ... text_to_html)
@@ -178,7 +207,8 @@
178 u'foo<img alt="" src="/@@/translation-newline" /><br/>\nbar'207 u'foo<img alt="" src="/@@/translation-newline" /><br/>\nbar'
179208
180209
181== convert_newlines_to_web_form ==210convert_newlines_to_web_form
211----------------------------
182212
183 >>> from lp.translations.browser.browser_helpers import (213 >>> from lp.translations.browser.browser_helpers import (
184 ... convert_newlines_to_web_form)214 ... convert_newlines_to_web_form)
@@ -194,7 +224,8 @@
194 u'foo\r\nbar'224 u'foo\r\nbar'
195225
196226
197== count_lines ==227count_lines
228-----------
198229
199 >>> from lp.translations.browser.browser_helpers import count_lines230 >>> from lp.translations.browser.browser_helpers import count_lines
200 >>> count_lines("foo")231 >>> count_lines("foo")
@@ -216,8 +247,8 @@
216 ... "1234566789a123456789a")247 ... "1234566789a123456789a")
217 2248 2
218 >>> count_lines(249 >>> count_lines(
219 ... "123456789abc123456789abc123456789abc123456789abc123456789abc123456\n"250 ... "123456789abc123456789abc123456789abc123456789abc123456789abc"
220 ... "789a123456789a123456789a")251 ... "123456\n789a123456789a123456789a")
221 3252 3
222 >>> count_lines(253 >>> count_lines(
223 ... "123456789abc123456789abc123456789abc123456789abc123456789abc"254 ... "123456789abc123456789abc123456789abc123456789abc123456789abc"
224255
=== modified file 'lib/lp/translations/interfaces/translations.py'
--- lib/lp/translations/interfaces/translations.py 2010-08-20 20:31:18 +0000
+++ lib/lp/translations/interfaces/translations.py 2010-10-08 17:02:58 +0000
@@ -16,6 +16,7 @@
16 'TranslationsBranchImportMode',16 'TranslationsBranchImportMode',
17 )17 )
1818
19
19class TranslationConstants:20class TranslationConstants:
20 """Set of constants used inside the context of translations."""21 """Set of constants used inside the context of translations."""
2122
@@ -31,6 +32,8 @@
31 TAB_CHAR_ESCAPED = '<code>' + r'\[tab]' + '</code>'32 TAB_CHAR_ESCAPED = '<code>' + r'\[tab]' + '</code>'
32 NO_BREAK_SPACE_CHAR = '<code>[nbsp]</code>'33 NO_BREAK_SPACE_CHAR = '<code>[nbsp]</code>'
33 NO_BREAK_SPACE_CHAR_ESCAPED = '<code>' + r'\[nbsp]' + '</code>'34 NO_BREAK_SPACE_CHAR_ESCAPED = '<code>' + r'\[nbsp]' + '</code>'
35 NARROW_NO_BREAK_SPACE_CHAR = '<code>[nnbsp]</code>'
36 NARROW_NO_BREAK_SPACE_CHAR_ESCAPED = '<code>' + r'\[nnbsp]' + '</code>'
3437
3538
36class TranslationsBranchImportMode(DBEnumeratedType):39class TranslationsBranchImportMode(DBEnumeratedType):
@@ -54,5 +57,3 @@
54 Import all translation files (templates and translations)57 Import all translation files (templates and translations)
55 found in the branch.58 found in the branch.
56 """)59 """)
57
58