Bug 100128 - [Chromium] Convert Chromium template string to an LDML date format
Summary: [Chromium] Convert Chromium template string to an LDML date format
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Forms (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Kent Tamura
URL:
Keywords:
Depends on: 100129
Blocks: 97877
  Show dependency treegraph
 
Reported: 2012-10-23 08:48 PDT by Kent Tamura
Modified: 2012-10-26 18:54 PDT (History)
2 users (show)

See Also:


Attachments
Patch (2.25 KB, patch)
2012-10-24 00:17 PDT, Kent Tamura
no flags Details | Formatted Diff | Diff
Patch 2 (2.27 KB, patch)
2012-10-25 18:58 PDT, Kent Tamura
tony: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kent Tamura 2012-10-23 08:48:15 PDT
Need to convert a Chromium template string like "Week $2, $1" to an LDML date format like "'Week 'ww, yyyy"
Comment 1 Kent Tamura 2012-10-24 00:17:05 PDT
Created attachment 170333 [details]
Patch
Comment 2 Kent Tamura 2012-10-24 00:17:28 PDT
See https://codereview.chromium.org/11270005 too.
Comment 3 Tony Chang 2012-10-24 13:43:05 PDT
Comment on attachment 170333 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=170333&action=review

> Source/WebKit/chromium/src/LocalizedStrings.cpp:272
> +

Nit: extra blank line?

> Source/WebKit/chromium/src/LocalizedStrings.cpp:281
> +    unsigned literalStart = 0;
> +    unsigned length = templ.length();
> +    for (unsigned i = 0; i < length; ++i) {
> +        if (templ[i] == '$' && i + 1 < length && (templ[i + 1] == '1' || templ[i + 1] == '2')) {
> +            if (literalStart < i)

As I mentioned on the Chromium side, we should just put ww and yyyy in the template format. Then we can remove this code.

This probably isn't likely, but is it a problem if "ww" or "yyyy" appears in the translation?  Do we just match the first occurrence?
Comment 4 Kent Tamura 2012-10-24 20:57:09 PDT
Comment on attachment 170333 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=170333&action=review

>> Source/WebKit/chromium/src/LocalizedStrings.cpp:272
>> +
> 
> Nit: extra blank line?

will remove.

>> Source/WebKit/chromium/src/LocalizedStrings.cpp:281
>> +            if (literalStart < i)
> 
> As I mentioned on the Chromium side, we should just put ww and yyyy in the template format. Then we can remove this code.
> 
> This probably isn't likely, but is it a problem if "ww" or "yyyy" appears in the translation?  Do we just match the first occurrence?

For LDML date format pattern, we need to quote any latin alphabet.  If we didn't quote a string "Week" in a literal part, a letter 'W' would be recognized as week-of-month designator, 'ee' would be 2-digits day-of-week, 'k' would be 1-to-24 hour.
Comment 5 Kent Tamura 2012-10-25 18:58:44 PDT
Created attachment 170785 [details]
Patch 2

Remove a blank line. Add a comment
Comment 6 Tony Chang 2012-10-26 10:00:51 PDT
Comment on attachment 170785 [details]
Patch 2

View in context: https://bugs.webkit.org/attachment.cgi?id=170785&action=review

OK

> Source/WebKit/chromium/src/LocalizedStrings.cpp:281
> +    for (unsigned i = 0; i < length; ++i) {
> +        if (templ[i] == '$' && i + 1 < length && (templ[i + 1] == '1' || templ[i + 1] == '2')) {

I think you could just make the loop go to length - 1 and remove the i + 1 < length check.
Comment 7 Kent Tamura 2012-10-26 18:46:01 PDT
Comment on attachment 170785 [details]
Patch 2

View in context: https://bugs.webkit.org/attachment.cgi?id=170785&action=review

>> Source/WebKit/chromium/src/LocalizedStrings.cpp:281
>> +        if (templ[i] == '$' && i + 1 < length && (templ[i + 1] == '1' || templ[i + 1] == '2')) {
> 
> I think you could just make the loop go to length - 1 and remove the i + 1 < length check.

ok, I'll change the for-loop condition to "i + 1 < length" and remove "i + 1  < length" here
Comment 8 Kent Tamura 2012-10-26 18:54:46 PDT
Committed r132718: <http://trac.webkit.org/changeset/132718>