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

Automatic Eastern Arabic numerals in Arabic translations?H #583

Open
elisehein opened this issue Feb 15, 2022 · 1 comment
Open

Automatic Eastern Arabic numerals in Arabic translations?H #583

elisehein opened this issue Feb 15, 2022 · 1 comment

Comments

@elisehein
Copy link

elisehein commented Feb 15, 2022

Hi!

I'm having trouble finding documentation for this on projectfluent.org.

Given a Fluent translation in Arabic, and passing in an integer for the score...

feedback-score = لقد حصلت على {$SCORE} أشكال صحيحة.

Is there a way to convert the score to an eastern arabic numeral? I'm expecting to see لقد حصلت على ١٠ أشكال صحيحة. instead of لقد حصلت على 10 أشكال صحيحة..

I'm using @fluent/react for this.

MVP (ignoring cardinality variants for brevity):

import { FluentBundle, FluentResource } from "@fluent/bundle";
import { ReactLocalization, LocalizationProvider } from "@fluent/react";

function getTranslationResources() {
  return {
    "ar": new FluentResource("feedback-score = لقد حصلت على {$SCORE} أشكال صحيحة."),
    "en-GB": new FluentResource("feedback-score = You got {$SCORE} shapes right.")
  };
}

const TRANSLATION_RESOURCES = getTranslationResources();

function *generateBundle(locale) {
  const bundle = new FluentBundle(locale);
  bundle.addResource(TRANSLATION_RESOURCES[locale]);
  yield bundle;
}

function l10n(locale) {
  return new ReactLocalization(generateBundle(locale));
}

function Component() {
  return (
    <LocalizationProvider
      l10n={l10n("ar")}>
      <Localized
        id="feedback-score"
        vars={{ SCORE: 12 }} />
    </LocalizationProvider>
  );
}
@Pike
Copy link
Contributor

Pike commented Feb 15, 2022

This might be a bug. I've created a POC on https://projectfluent.org/play/?id=866991f31481b7590e6851ab103aed6a, and it renders the latin-ish arabic numbers. If I switch the language from Arabic to Breton and back to Arabic, it shows the arabic arabic number literal.

That's weird, no idea if that's a thing in playground or in fluent bundle or ...

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

No branches or pull requests

2 participants