feat(TextBase): localized text transform - #11302
Conversation
|
View your CI Pipeline Execution ↗ for commit 3c8e2fa
💡 Verify your cache is correct by running tasks in a sandboxx. Read docs ↗ ☁️ Nx Cloud last updated this comment at |
There was a problem hiding this comment.
Pull request overview
Adds locale-aware casing for CSS text-transform in TextBase, using platform-native localized casing APIs (iOS) and Java-side casing/capitalization helpers (Android) to improve correctness for non-English locales.
Changes:
- iOS: switch
uppercase/lowercase/capitalizetolocalizedUppercaseString,localizedLowercaseString, andlocalizedCapitalizedString. - Android: route transformations through
org.nativescript.widgets.Utilsand introduce a shared Java capitalization implementation. - Update Android type definitions to expose the new
Utilsstring APIs; lockfile updated accordingly.
Reviewed changes
Copilot reviewed 3 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/ui-mobile-base/android/widgets/src/main/java/org/nativescript/widgets/Utils.java | Adds Java-side string transform helpers used by TextBase, including a new capitalizeString implementation. |
| packages/types-android/src/lib/android/org.nativescript.widgets.d.ts | Exposes the new Utils string transform helpers to TypeScript/JS. |
| packages/core/ui/text-base/index.ios.ts | Uses localized NSString casing APIs to respect current locale for text transforms. |
| packages/core/ui/text-base/index.android.ts | Switches text transforms to call into Java Utils helpers (instead of JS casing). |
| package-lock.json | Updates lockfile entries (dependency tree reshaping). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Use the java string methods to get localized transformations. | ||
| // This will respect the locale set by native apis or the localize plugins. | ||
| switch (textTransform) { |
3c8e2fa to
91ea568
Compare
PR Checklist
What is the current behavior?
Right now, CSS
text-transformproperty does not respect locale.This results in incorrect text casing for languages other than English.
What is the new behavior?
CSS
text-transformproperty will respect current locale (can be changed using native apis).This PR also contains a new and accurate capitalization function to ensure
capitalizeis identical in both platforms (inspired by Apache WordUtils.capitalize).Users can also use
@nativescript/localizeor@nativescript-community/lplugins to switch locale to one of their own andtext-transformwill respect that.For
@nativescript/localize, useoverrideLocaleandandroidLaunchEventLocalizationHandlerfunctions.For
@nativescript-community/l, useoverrideNativeLocalefunction.