Skip to content

Add Arabic numeral preferences and update locale handling#3544

Open
alti3 wants to merge 2 commits intoquran:mainfrom
alti3:feat/arabic-numerals
Open

Add Arabic numeral preferences and update locale handling#3544
alti3 wants to merge 2 commits intoquran:mainfrom
alti3:feat/arabic-numerals

Conversation

@alti3
Copy link

@alti3 alti3 commented Feb 20, 2026

Implemented an Arabic numeral choice in Arabic mode, with Eastern/Western options and runtime locale wiring.

What I changed

  • Added a new display setting in Settings for Arabic numeral style:
    • app/src/main/res/xml/quran_preferences.xml:23
    • Key: app/src/main/res/values/preferences_keys.xml:42
    • Entries/values:
      • app/src/main/res/values/arrays.xml:21
      • app/src/main/res/values-ar/arrays.xml:9
    • Labels:
      • app/src/main/res/values/strings.xml:167
      • app/src/main/res/values-ar/strings.xml:235
  • Added constants for this preference/value set:
    • app/src/main/java/com/quran/labs/androidquran/data/Constants.kt:92
  • Added locale-tag helpers to support Arabic with numeral system extension:
    • Eastern: ar-EG-u-nu-arab
    • Western: ar-EG-u-nu-latn
    • app/src/main/java/com/quran/labs/androidquran/util/QuranUtils.java:30
  • Updated settings behavior:
    • Numeral selector is shown only when Arabic mode is active.
    • Toggling Arabic mode on uses selected numeral system.
    • Changing numeral style while in Arabic mode reapplies app locales immediately.
    • app/src/main/java/com/quran/labs/androidquran/ui/fragment/QuranSettingsFragment.kt:53
  • Updated Arabic-number formatting paths to honor chosen Arabic locale when app language is Arabic:
    • Playback number pickers: app/src/main/java/com/quran/labs/androidquran/ui/fragment/AyahPlaybackFragment.kt:99
    • Ayah markers: common/drawing/src/main/java/com/quran/labs/androidquran/common/drawing/helper/AyahMarkerDrawer.kt:45
    • Line-by-line ayah numbers: feature/linebyline/src/main/java/com/quran/labs/androidquran/extra/feature/linebyline/QuranLineByLineWrapperView.kt:89

Validation

  • Passed:
    • :app:processMadaniDebugResources
    • :common:drawing:compileReleaseKotlin
  • Full app/module Kotlin compilation is currently blocked by existing SQLDelight/Metro environment issues unrelated to these edits (tasks
    like :common:translation:generateReleaseTranslationsDatabaseInterface, :common🔖generateReleaseBookmarksDatabaseInterface, and line-by-line DB interface generation).

- Introduced preferences for selecting Arabic numeral systems (Eastern and Western) in settings.
- Updated `QuranSettingsFragment` to handle numeral system changes.
- Enhanced `AyahPlaybackFragment` to format numbers based on selected numeral system.
- Refactored `QuranUtils` to support locale-based numeral formatting.
- Updated UI components to reflect new preferences and ensure proper display of Arabic numerals.
@ahmedre
Copy link
Contributor

ahmedre commented Feb 22, 2026

jazakumAllah khairan for the pr
honest question though - why not instead of this just fix it so that when the person chooses a region with 123 numbers instead of ١٢٣ numbers that the app doesn't override it by explicitly requesting an ar_EG locale? benefits of this would be:

  • no need for a custom setting on our end
  • we respect whatever the person is used to using out of the box

wdyt?

@alti3
Copy link
Author

alti3 commented Feb 22, 2026

jazakumAllah khairan for the pr honest question though - why not instead of this just fix it so that when the person chooses a region with 123 numbers instead of ١٢٣ numbers that the app doesn't override it by explicitly requesting an ar_EG locale? benefits of this would be:

  • no need for a custom setting on our end
  • we respect whatever the person is used to using out of the box

wdyt?

Would you need extra permission to read user's/device locale?

@ahmedre
Copy link
Contributor

ahmedre commented Feb 23, 2026

Would you need extra permission to read user's/device locale?

nope - see this post for more details

- Updated `QuranUtils`, `AyahMarkerDrawer`, and `QuranLineByLineWrapperView` to use a more flexible locale construction method for Arabic, allowing for better handling of regional variations.
- Replaced hardcoded locale tags with dynamic locale builders to enhance compatibility with different Arabic numeral systems.
- Ensured consistent locale handling across components for improved user experience.
@alti3
Copy link
Author

alti3 commented Feb 23, 2026

Would you need extra permission to read user's/device locale?

nope - see this post for more details

nicely written article, mashallah
I've updated the implementation to be based on device locale

@alti3
Copy link
Author

alti3 commented Feb 23, 2026

What changed

  • app/src/main/java/com/quran/labs/androidquran/util/QuranUtils.java:118
    • getArabicLocaleTagForNumeralSystem(...) now builds an Arabic locale tag using the current locale’s region (or device default region fallback) and only applies nu (arab/latn),
      instead of fixed ar-EG-*.
  • app/src/main/java/com/quran/labs/androidquran/util/QuranUtils.java:133
    • getArabicNumeralLocale(...) now returns Arabic with region derived from user/device locale context, not ar-EG.
  • common/drawing/src/main/java/com/quran/labs/androidquran/common/drawing/helper/AyahMarkerDrawer.kt:81
    • Non-Arabic fallback locale now becomes ar-<current/device-country> via Locale.Builder, not ar-EG.
  • feature/linebyline/src/main/java/com/quran/labs/androidquran/extra/feature/linebyline/QuranLineByLineWrapperView.kt:118
    • Same country-aware Arabic locale fallback instead of ar-EG.

Verification

  • :common:drawing:compileReleaseKotlin passed.
  • Full app/module compiles are currently blocked by existing environment/repo issues unrelated to this patch:
    • missing google-services.json
    • existing SQLDelight generation failures (common:linebyline:data, common:bookmark)
    • pre-existing Metro/Kotlin compiler internal errors in translation/bookmark paths.

Source read

Copy link
Contributor

@ahmedre ahmedre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

جزاكم الله خيراً
I think the code looks good and this makes sense. I was on the fence about whether or not we need a setting but a good counter-argument is that we have a setting for arabic mode anyway, so it probably makes sense. I just need to test before merging.

one question for you - we don't draw the ayah numbers on all page types (ex 1405 pages, tajweed pages, etc) - should we point out that in the setting description that it may not apply to all page types to avoid people being confused?

also, I didn't test it yet but does this also update the page number, rub3 / juz' info, etc?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants