[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: l10n-support/pology/misc
From: Chusslove Illich <caslav.ilic () gmx ! net>
Date: 2010-01-15 22:35:04
Message-ID: 1263594904.262949.13770.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 1075359 by ilic:
Smarter lowercasing.
M +15 -6 resolve.py
--- trunk/l10n-support/pology/misc/resolve.py #1075358:1075359
@@ -295,15 +295,15 @@
In that case, if the first letter is found within an alternative, change
cases for first letters in other alternatives of the same directive too.
+ If lowercasing is requested, it is not done if both the first and
+ the second letter are uppercase (e.g. acronyms, all-caps writting).
+
@param text: the text to transform
@type text: string
-
@param upper: whether to transform to uppercase (lowercase otherwise)
@type upper: bool
-
@param nalts: if non-zero, the number of alternatives per directive
- @type nalts: int >= 0
-
+ @type nalts: int
@param althead: alternatives directive head instead of the default one
@type althead: string
@@ -370,8 +370,17 @@
cseg = text[i0:i]
if cchange:
ncchanged += 1
- if upper: textcc += cseg.upper()
- else: textcc += cseg.lower()
+ if upper:
+ textcc += cseg.upper()
+ else:
+ # Find first next letter, for two-uppercase check.
+ i1 = i
+ while i1 < tlen and not text[i1].isalpha():
+ i1 += 1
+ if i1 == tlen or not cseg.isupper() or not text[i1].isupper():
+ textcc += cseg.lower()
+ else:
+ textcc += cseg
else:
textcc += cseg
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic