Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(android): add Intl DateTimeFormat, NumberFormat, and Collator #11698

Closed
wants to merge 25 commits into from

Conversation

jquick-axway
Copy link
Contributor

@jquick-axway jquick-axway commented May 9, 2020

JIRA:

Summary:
(iOS already supports the below. Adding to Android for parity.)

  • Added Intl.Collator support.
  • Added Intl.DateTimeFormat support.
  • Added Intl.NumberFormat support.
  • Added locale/options support to below methods. (Used to only support 'en-US'.)
    • Date.toLocaleString()
    • Date.toLocaleDateString()
    • Date.toLocaleTimeString()
    • Number.toLocaleString()
    • String.localeCompare()
    • String.toLocaleLowerCase()
    • String.toLocaleUpperCase()

Test:

  1. Build and run the below on Android.
  2. Set device's region/locale to US English.
  3. Launch the app and verify it shows the below.
    <Month>/<Day>/<Year>
    1,234,567.8
    $1,234.56
  4. Set device's region/locale to Germany (aka: Deutchland).
  5. Re-launch app and verify it shows the below.
    <Day>.<Month>.<Year>
    1.234.567,8
    1.234,56 €
  6. Set device's region/locale to Japan (aka: 日本語 (日本))
  7. Re-launch app and verify it shows the below.
    <Year>/<Month>/<Day>
    1,234,567.8
    ¥ 1,235

app.js

var locale = Ti.Locale.currentLocale;
var window = Ti.UI.createWindow({ layout: "vertical" });
window.add(Ti.UI.createLabel({
	text: (new Date()).toLocaleDateString(locale),
	top: Ti.App.iOS ? "30dp" : "10dp",
}));
window.add(Ti.UI.createLabel({
	text: (1234567.8).toLocaleString(locale),
	top: "10dp",
}));
window.add(Ti.UI.createLabel({
	text: (1234.56).toLocaleString(locale, {
		style: 'currency',
		currency: Ti.Locale.getCurrencyCode(locale),
	}),
	top: "10dp",
}));
window.open();

- Implemented as Java proxies instead of #if-ing in V8's "Intl" which would add 20 MB per architecture.
- Modified toLocaleString(), toLocaleDateString(), and toLocaleTimeString() methods to support locale/options.
@build
Copy link
Contributor

build commented May 9, 2020

Warnings
⚠️

Commit 6f2feaec3a19734b42f83f512b43cfe5a9e63c4e has a message "feat(android): add Intl DateTimeFormat, NumberFormat, and Collator

  • Implemented as Java proxies instead of #if-ing in V8's "Intl" which would add 20 MB per architecture.
  • Modified toLocaleString(), toLocaleDateString(), and toLocaleTimeString() methods to support locale/options." giving 1 errors:
  • body's lines must not be longer than 100 characters
⚠️

Commit f3997154b89e30890b88f101bda834617365ca92 has a message "doc: supported Intl APIs" giving 1 errors:

  • type must be one of [build, chore, ci, docs, feat, fix, perf, refactor, revert, style, test]
Messages
📖

💾 Here's the generated SDK zipfile.

📖

🚨 This PR has one or more commits with warnings/errors for commit messages not matching our configuration. You may want to squash merge this PR and edit the message to match our conventions, or ask the original developer to modify their history.

📖

✅ All tests are passing
Nice one! All 6767 tests are passing.
(There are 698 skipped tests not included in that total)

Generated by 🚫 dangerJS against 226f5b1

- Engineering notation exponent must be in increments of 3.
- Modified engineering/scientific notation to respect fraction digit settings.
- Added iOS to several Intl.NumberFormat unit tests.
- Added egnineering notation unit test.
@sgtcoolguy
Copy link
Contributor

We should add the Intl APIs to the docs under the Global folder.

- Modifed compare() method to be bound to instance by default.
- Allows compare method to be passed by reference to sort() function and other functions.
- Doing a "new" on lambdas is non-standard and not supported by newest V8 runtime.
- Removed unneeded eslint-disable comments.
- Optimized common JS files to use OS_ANDROID blocks.
- Added missing JS "new" operators.
@build build added the docs label Jun 12, 2020
- Added formatToParts() unit tests to iOS.
- Added Intl constructor checks.
- Added Collator language sensitive unit test.
- Modified to match behavior in JavaScriptCore and node.js/V8.
  * 1st argument must be locales. Cannot be treated as options argument.
- Added locale support to:
  * String.localeCompare()
  * String.toLocaleLowerCase()
  * String.toLocaleUpperCase()
@sgtcoolguy
Copy link
Contributor

manually rebase/merged to master, 9_1_X, 9_3_X

@sgtcoolguy sgtcoolguy closed this Jul 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants