Commit graph

5287 commits

Author SHA1 Message Date
André Bargull
27cd54a779 Bug 1693576 - Part 8: Add a method to retrieve week day information to Calendar. r=platform-i18n-reviewers,gregtatum
The last addition for the "Intl Locale Info API" proposal.

Differential Revision: https://phabricator.services.mozilla.com/D125578
2021-09-21 08:51:22 +00:00
André Bargull
ea30633946 Bug 1693576 - Part 7: Add method to enumerate over all time zones used in a region. r=platform-i18n-reviewers,gregtatum
The filter type is `UCAL_ZONE_TYPE_ANY` to ensure all possible time zones are
returned, and not just CLDR canonical time zones. (CLDR canonical time zones
are different from IANA canonical time zones.)

Differential Revision: https://phabricator.services.mozilla.com/D125576
2021-09-21 08:51:22 +00:00
André Bargull
17e8b2c855 Bug 1693576 - Part 6: Rename GetDefaultTimeZoneOffsetMs() to GetRawOffsetMs(). r=platform-i18n-reviewers,gregtatum
- `TimeZone` objects can be created with any time zone identifier, so the "Default"
  part in the name isn't correct.
- The "TimeZone" part is no longer needed, now that there's a distinct class for
  `TimeZone` objects.

Therefore let's rename `GetDefaultTimeZoneOffsetMs()` to `GetRawOffsetMs()`.

Differential Revision: https://phabricator.services.mozilla.com/D125575
2021-09-21 08:51:21 +00:00
André Bargull
5638c044f2 Bug 1693576 - Part 5: Move time zone functions from mozilla::Calendar into mozilla::TimeZone. r=platform-i18n-reviewers,gregtatum
Time zone functions being part of `UCalendar` is an internal implementation
detail of ICU4C. For the public unified Intl API we should rather follow
Temporal (or ICU4C's C++ API) and have a separate `TimeZone` class.

The files were moved using `hg cp` to preserve the file history.

Differential Revision: https://phabricator.services.mozilla.com/D125574
2021-09-21 08:51:21 +00:00
André Bargull
67b7d804e6 Bug 1693576 - Part 3: Add NumberingSystem class to the unified Intl API component. r=platform-i18n-reviewers,gregtatum
Differential Revision: https://phabricator.services.mozilla.com/D125572
2021-09-21 08:51:20 +00:00
André Bargull
1919267c6d Bug 1693576 - Part 2: Add DateTimeFormat::GetAllowedHourCycles(). r=platform-i18n-reviewers,gregtatum
ICU's public API only provides a function to return the preferred hour cycle
(`udatpg_getDefaultHourCycle()`), whereas for `Intl.Locale` we want to be able
to determine all allowed hour cycles. So we have to do it the hard way and
directly read ICU resource bundles to get the data we need for this feature.

Differential Revision: https://phabricator.services.mozilla.com/D125571
2021-09-21 08:51:20 +00:00
André Bargull
ed57b49cb4 Bug 1693576 - Part 1: Add "commonlyUsed" to Calendar and Collator. r=platform-i18n-reviewers,gregtatum
Pass through the "commonlyUsed" parameter to ICU to be able to filter any
uncommon keyword values.

Differential Revision: https://phabricator.services.mozilla.com/D125570
2021-09-21 08:51:19 +00:00
Mike Kaply
0bb7a057b2 Bug 1726214 - For MSIX, install the addons in the corresponding language directory. r=mixedpuppy,nalexander,platform-i18n-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D123673
2021-09-20 22:55:35 +00:00
André Bargull
ee78515033 Bug 1719733 - Part 1: Add a MeasureUnit class to the unified Intl API. r=platform-i18n-reviewers,dminor
Currently only provides a single method to retrieve all available measurement units.

`MeasureUnit::GetAvailable()` returns an enumeration similar to the other Intl
classes which use `intl::Enumeration`. This approach gives us a more consistent
API, because it abstracts away the internal ICU implementation, which looks up
the measurement units through `UResourceBundle`. But it also means the
implementation is slightly more complicated due to this additional abstraction.

The default constructor was deleted because all methods are static.

Differential Revision: https://phabricator.services.mozilla.com/D125966
2021-09-20 20:04:17 +00:00
André Bargull
a5116d4ff5 Bug 1728184 - Part 1: Add a Currency class to the unified Intl API. r=platform-i18n-reviewers,dminor
Currently only provides a single method to retrieve all ISO currency codes.

The default constructor was deleted because all methods are static.

Depends on D125674

Differential Revision: https://phabricator.services.mozilla.com/D125675
2021-09-17 10:15:36 +00:00
André Bargull
e50c440591 Bug 1728183 - Part 2: Add Collator::GetBcp47KeywordValues() method to retrieve all possible collations. r=platform-i18n-reviewers,dminor
In contrast to the existing `GetBcp47KeywordValuesForLocale()` method, this
method returns all possible collation types, even the ones which aren't supported
by a specific locale.

Depends on D125672

Differential Revision: https://phabricator.services.mozilla.com/D125673
2021-09-17 10:15:35 +00:00
Yoshi Cheng-Hao Huang
7ded87e9a4 Bug 1728104 - Part 4: Merge NumberFormatFieldsUtil.[cpp|h] into NumberFormatFields.[cpp|h]. r=platform-i18n-reviewers,anba,dminor
Differential Revision: https://phabricator.services.mozilla.com/D125758
2021-09-16 14:47:03 +00:00
Yoshi Cheng-Hao Huang
70b53c7640 Bug 1728104 - Part 3: Remove NumberFormatFields.h from exported headers. r=platform-i18n-reviewers,anba,dminor
Differential Revision: https://phabricator.services.mozilla.com/D125757
2021-09-16 14:47:03 +00:00
Yoshi Cheng-Hao Huang
0b48e561d6 Bug 1728104 - Part 2: Add NumberPart.h. r=platform-i18n-reviewers,anba,dminor
Differential Revision: https://phabricator.services.mozilla.com/D125684
2021-09-16 14:47:02 +00:00
Yoshi Cheng-Hao Huang
234cb720ff Bug 1728104 - Part 1: Fix non-unified build error on ListFormat.cpp. r=tcampbell
Differential Revision: https://phabricator.services.mozilla.com/D125683
2021-09-16 14:47:02 +00:00
Jonathan Kew
da9c992100 Bug 1729642 - patch 1 - Make shutdown of nsLanguageAtomService explicit instead of relying on ClearOnShutdown. r=platform-i18n-reviewers,dminor
Differential Revision: https://phabricator.services.mozilla.com/D125587
2021-09-14 18:51:49 +00:00
André Bargull
b8019db021 Bug 1730508 - Part 3: Enable UnusedZero and HasFreeLSB Result optimisations. r=platform-i18n-reviewers,gregtatum,dminor
Differential Revision: https://phabricator.services.mozilla.com/D125410
2021-09-14 16:10:10 +00:00
André Bargull
2ffa3169a5 Bug 1730508 - Part 2: Remove unused function NullTerminatedMapper. r=platform-i18n-reviewers,gregtatum
Differential Revision: https://phabricator.services.mozilla.com/D125409
2021-09-14 16:10:09 +00:00
André Bargull
b1647a4555 Bug 1730508 - Part 1: Propagate ICUError where possible. r=platform-i18n-reviewers,gregtatum
Fully propagate `ICUError` instead of using `InternalError`.

Differential Revision: https://phabricator.services.mozilla.com/D125408
2021-09-14 16:10:09 +00:00
André Bargull
82ecb29b4c Bug 1639515 - Part 4: Update docs to point to Intl.DisplayNames. r=platform-i18n-reviewers,gregtatum
Update the documention to mention `Intl.DisplayNames` instead of
`Intl.getDisplayNames`.

Differential Revision: https://phabricator.services.mozilla.com/D76116
2021-09-14 09:20:32 +00:00
criss
59cdd2a63e Backed out 6 changesets (bug 1639515) for causing failures on test_intlUtils_getDisplayNames.html. CLOSED TREE
Backed out changeset eaff696ed6a6 (bug 1639515)
Backed out changeset 6d361f92b27e (bug 1639515)
Backed out changeset 6919213b03f7 (bug 1639515)
Backed out changeset 5a08d3b17fa7 (bug 1639515)
Backed out changeset 3681111b7ed3 (bug 1639515)
Backed out changeset 970826244d07 (bug 1639515)
2021-09-14 10:45:35 +03:00
André Bargull
252e2973ec Bug 1639515 - Part 4: Update docs to point to Intl.DisplayNames. r=platform-i18n-reviewers,gregtatum
Update the documention to mention `Intl.DisplayNames` instead of
`Intl.getDisplayNames`.

Differential Revision: https://phabricator.services.mozilla.com/D76116
2021-09-14 06:52:33 +00:00
Jonathan Kew
2535a4390c Bug 1730084 Part 6 - Add some empty fragments to the word-breaker test data. r=TYLin
Differential Revision: https://phabricator.services.mozilla.com/D125180
2021-09-13 23:55:34 +00:00
Ting-Yu Lin
f8152b2b24 Bug 1730084 Part 5 - Remove WordBreaker::BreakInBetween(). r=jfkthame
The motivation of this patch is to remove rarely used API in
WordBreaker. WordBreaker::BreakInBetween() is used only in
nsFind::BreakInBetween() in production, and it can be replaced by
Next().

If the user wants to know whether there is a word break between two
strings such as the use cases in gtest, joining the two strings and
passing the result to Next() is the preferred way.

Note: I delete the buggy forward word search algorithm in
TestFindWordBreakFromPosition() because from the test expectations, it
doesn't expect to continue the search in previous fragments. Also, the
buggy part comes from the following code, which had undefined behavior
before Part 4, and does nothing after Part 4.

```
wbk->FindWord(prevFragText.get(), prevFragText.Length(), prevFragText.Length());
```

Differential Revision: https://phabricator.services.mozilla.com/D125151
2021-09-13 23:55:33 +00:00
Ting-Yu Lin
bd25bca479 Bug 1730084 Part 4 - Clean up and fix an edge case of FindWord(). r=jfkthame
* Rename arguments so that their names are consistent with Next().
* Make the function not assert on an empty string, i.e. aLen == 0, like
Next().
* Fix an undefined behavior when the user passes aTextLen == aOffset.
The methods used to access `aText[aOffset]` that is clearly out of range
because the string may not be null-terminated. After this patch, it
returns a sentinel WordRange when aLen == aPos.
* Add document and gtest TestFindWordWithEmptyString().
* Change the sentinel return value to {aLen,aLen} for FindWord(), and
adapt one caller.

Differential Revision: https://phabricator.services.mozilla.com/D125434
2021-09-13 23:55:33 +00:00
Ting-Yu Lin
b94f1b97c5 Bug 1730084 Part 1 - Run TestNextWordBreakWithEmptyString as a test. r=jfkthame
The function is added in Bug 1728708 Part 4, but it never get called, so
this patch transforms it into a test in WordBreak test suite to make it
run.

While I'm here, other individual functions are also transformed into
tests so that we can have more granular results if some of them failed.

Differential Revision: https://phabricator.services.mozilla.com/D125148
2021-09-13 23:55:32 +00:00
Greg Tatum
b0d6525aca Bug 1719696 - Cache the original skeleton, and use it in DateIntervalFormat; r=anba,platform-i18n-reviewers,dminor
Differential Revision: https://phabricator.services.mozilla.com/D125254
2021-09-13 20:53:01 +00:00
Greg Tatum
21e515adad Bug 1719696 - Rework FillUTF8Buffer to FillBuffer; r=platform-i18n-reviewers,dminor
Differential Revision: https://phabricator.services.mozilla.com/D125252
2021-09-13 20:53:00 +00:00
Greg Tatum
8c790b7cb7 Bug 1719696 - Add ICUPointer to DateTimePatternGenerator; r=platform-i18n-reviewers,dminor
Differential Revision: https://phabricator.services.mozilla.com/D124498
2021-09-13 20:53:00 +00:00
Greg Tatum
129339b6b8 Bug 1719696 - Create a components bag abstraction for mozilla::intl::DateTimeFormat; r=anba,platform-i18n-reviewers,dminor
This patch will probably not compile on its own, but requires the SpiderMonkey
side as well. It aims at building a components bag interface that can be
then used in SpiderMonkey to back the ECMA 402 API.

Differential Revision: https://phabricator.services.mozilla.com/D123822
2021-09-13 20:52:59 +00:00
Greg Tatum
b2eb7b49ba Bug 1719696 - Naively move the hour cycle computations; r=anba,platform-i18n-reviewers,dminor
This patch will not compile. It naively copies over the hour cycle code
from SpiderMonkey into the unified components. In a following patch,
these will be modified to use only the unified types.

Differential Revision: https://phabricator.services.mozilla.com/D123821
2021-09-13 20:52:59 +00:00
Greg Tatum
3971654d9f Bug 1719696 - Add a nicer assertion for checking the buffer contents; r=platform-i18n-reviewers,dminor
Differential Revision: https://phabricator.services.mozilla.com/D123820
2021-09-13 20:52:58 +00:00
Greg Tatum
7eeb5c0b59 Bug 1719696 - Use ICUError in mozilla::intl::DateTimeFormat; r=platform-i18n-reviewers,dminor
This is part of the work for Bug 1713206

Differential Revision: https://phabricator.services.mozilla.com/D123819
2021-09-13 20:52:58 +00:00
André Bargull
067c27c5ab Bug 1728182 - Part 2: Remove getLocaleInfo from toolkit. r=platform-i18n-reviewers,dminor
Depends on D125160

Differential Revision: https://phabricator.services.mozilla.com/D125163
2021-09-12 13:45:21 +00:00
Greg Tatum
238d8b17c7 Bug 1715980 - Fix the calendar keyword in Calendar::GetBcp47Type docs; r=platform-i18n-reviewers,dminor DONTBUILD
Differential Revision: https://phabricator.services.mozilla.com/D124982
2021-09-09 14:57:37 +00:00
Yoshi Cheng-Hao Huang
d92ecbcd8b Bug 1719747 - Part 3: ListFormat::FormatToParts takes a callback. r=gregtatum,tcampbell
As discussed in https://bugzilla.mozilla.org/show_bug.cgi?id=1719747#c6,
In Part 1, the ownership of the Span in PartsVector is maintained by
ICU. This method adds a callback so js::intl::ListFormat could copy the
content of the Span to Spidermonkey, and mozilla::intl::ListFormat could
use ScopedICUObject to release the string owned by ICU earlier.

Differential Revision: https://phabricator.services.mozilla.com/D123166
2021-09-09 12:02:22 +00:00
Yoshi Cheng-Hao Huang
39cadacc67 Bug 1719747 - Part 1: Unify ListFormat in SM. r=gregtatum,anba,platform-i18n-reviewers,tcampbell
Move implementations to mozilla::intl::ListFormat

Differential Revision: https://phabricator.services.mozilla.com/D122334
2021-09-09 12:02:21 +00:00
Greg Tatum
12c9670cc5 Bug 1713206 - Propagate ICU statuses to ICUErrors; r=platform-i18n-reviewers,dminor
Depends on D124963

Differential Revision: https://phabricator.services.mozilla.com/D124964
2021-09-08 21:36:29 +00:00
Greg Tatum
46c00b33ef Bug 1713206 - Flatten nested namespaces in mozilla::intl components; r=platform-i18n-reviewers,dminor
This is a drive-by clean-up while I'm working on errors.

Depends on D124962

Differential Revision: https://phabricator.services.mozilla.com/D124963
2021-09-08 21:36:29 +00:00
Greg Tatum
e5f56207b3 Bug 1713206 - Add missing ICUError.h headers; r=platform-i18n-reviewers,dminor
Depends on D124961

Differential Revision: https://phabricator.services.mozilla.com/D124962
2021-09-08 21:36:29 +00:00
Greg Tatum
65a2bb16fc Bug 1713206 - Use ICUError in mozilla::intl::PluralRules; r=platform-i18n-reviewers,dminor
Depends on D124960

Differential Revision: https://phabricator.services.mozilla.com/D124961
2021-09-08 21:36:28 +00:00
Greg Tatum
b917c44dd2 Bug 1713206 - Use ICUError in mozilla::intl::DateTimePatternGenerator; r=platform-i18n-reviewers,dminor
Depends on D124959

Differential Revision: https://phabricator.services.mozilla.com/D124960
2021-09-08 21:36:28 +00:00
Greg Tatum
c5836fc86a Bug 1713206 - Use ICUError in mozilla::intl::Calendar; r=platform-i18n-reviewers,dminor
Differential Revision: https://phabricator.services.mozilla.com/D124959
2021-09-08 21:36:27 +00:00
Ting-Yu Lin
57b867e7ff Bug 1728708 Part 4 - Simplify WordBreaker::Next() and make it recognize the end of text a word break opportunity. r=jfkthame
A UAX29 compatible word breaker (like ICU4C) treat the end of text as a
word break opportunity (rule WB2 [1]), but currently lwbrk word breaker
doesn't.

The motivation of this patch is to make `WordBreaker::Next()` closer to
a UAX29 compatible one (at least for English text), and see if the
callers need to change. This should make the future integration of ICU4X
segmenter easier.

The only caller of WordBreaker::Next() is ClusterIterator's constructor.
This patch shouldn't change its behavior because we've already manually
assigned a word break point at the end of the line when `aContext` is
empty and `aDirection` is -1. This patch generalizes it to all
conditions.

Also, update TestPrintWordWithBreak() so that the result string makes
more sense.

[1] https://www.unicode.org/reports/tr29/#WB2

Differential Revision: https://phabricator.services.mozilla.com/D124304
2021-09-08 04:19:38 +00:00
Ting-Yu Lin
edb9c8ed39 Bug 1728708 Part 3 - Clean up the gtest for line and word breaker. r=jfkthame
Here are the changes in this patch. They shouldn't change the behavior.

* Rename the gtest to `TestBreak.cpp` because it also contains word break tests.
* Align ruler comments to the test strings.
* Rename `lb` to `wb` in `TestASCIIWB`.
* Remove unused variable `j` in `TestPrintWordWithBreak()`.
* Use `ArrayLength` instead of `sizeof` trick to get the array length.
* #include ArrayUtils.h, and sort the #includes statements.

Differential Revision: https://phabricator.services.mozilla.com/D124303
2021-09-08 04:19:37 +00:00
Ting-Yu Lin
69a841c529 Bug 1728708 Part 2 - Rename WordBreaker::NextWord() to WordBreaker::Next(). r=jfkthame
Differential Revision: https://phabricator.services.mozilla.com/D124302
2021-09-08 04:19:37 +00:00
Ting-Yu Lin
1083821003 Bug 1728708 Part 1 - Move WordBreakClass and GetClass into WordBreaker's private section. r=jfkthame
Differential Revision: https://phabricator.services.mozilla.com/D124301
2021-09-08 04:19:36 +00:00
Greg Tatum
7666a8132a Bug 1719540 - Fix unified build imports bustages for mozilla::intl; r=dminor
Depends on D120249

Differential Revision: https://phabricator.services.mozilla.com/D124116
2021-09-01 00:02:31 +00:00
Greg Tatum
443160a426 Bug 1719540 - Implement a unified Locale canonicalizer; r=platform-i18n-reviewers,dminor
I used the C api here, but verified that the behavior was the same
as using the C++ getBaseName API.

927fee5656/src/features/icu.cpp (L249-L268)

I tried to keep the implementation naming at least similar to the
work in: https://phabricator.services.mozilla.com/D118070

However, the implementation do diverge. I figure in the future, the
APIs can be made similar, but at least the gtests will ensure the
behavior remains the same.

Differential Revision: https://phabricator.services.mozilla.com/D120248
2021-09-01 00:02:30 +00:00
Alexandru Michis
7be95b70ef Backed out 2 changesets (bug 1719540) for causing bustages in RelativeTimeFormat.cpp
CLOSED TREE

Backed out changeset a6ab150a89f2 (bug 1719540)
Backed out changeset e8b05f56aa75 (bug 1719540)
2021-08-31 21:14:11 +03:00