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

canTranslate values no, readily and afterDownload are not internationalized? #12

Open
aphillips opened this issue Jun 6, 2024 · 2 comments
Labels
i18n-needs-resolution Issue the Internationalization Group has raised and looks for a response on.

Comments

@aphillips
Copy link

Various locations in the readme, including:
https://github.com/WICG/translation-api/blob/main/README.md#for-a-known-source-language

We do not intend to force every browser to ship language packs for every language combination, or even to support translation at all. It would be conforming to implement this API by always returning "no" from canTranslate(),

The value for canTranslate() uses English keywords or phrases and some of these ("readily" and "afterDownload") are somewhat idiomatic. The justification for not making this method return boolean type values true and false is that there is a third value afterDownload and that using the boolean keywords would be inconsistent with JS practice (for a variety of reasons).

I would still probably prefer something more like true/false/download or perhaps yes/no/downloadRequired. The values yes and no might be consistent with values for the not-exactly-related attribute translate in ITS.

@aphillips aphillips added the i18n-needs-resolution Issue the Internationalization Group has raised and looks for a response on. label Jun 6, 2024
@domenic
Copy link
Collaborator

domenic commented Jul 26, 2024

In general JavaScript enums are not internationalized, so this issue is a bit surprising. E.g. other platform enums that are similar are

enum DocumentReadyState { "loading", "interactive", "complete" };
enum CanPlayTypeResult { "" /* empty string */, "maybe", "probably" };
enum TextTrackMode { "disabled",  "hidden",  "showing" };

I don't recall any requests to internationalize these, or other, JavaScript enums.

As you note, a true boolean is not possible here. Given that, I think it would be pretty surprising to use the string "false", which in JavaScript is truthy. So I like using "no" instead. (Although, see #7.)

And I think "readily" is more accurate than the string "true", as for both the readily-available and after-download cases, it's "true" that you can translate in this browser. It's just a matter of whether you can do so readily, or only after a download.

I don't think I understand the relevance of ITS. It seems to be an XML vocabulary, not a JavaScript API?

@aphillips
Copy link
Author

I probably titled this wrong. By "internationalized" here, I do not mean "localized into different languages". What I'm trying to get at by bikeshedding the value names (and let's stipulate that I am bikeshedding) is...

Users of JS APIs are generally software developers and thus have some familiarity with English. However, fluency varies greatly. To ensure the users understand an API, enum values should be chosen that do not depend on English idiom, humor, or other interpretation. In this case, I think the term readily is unclear, especially to non-native speakers.

In your list of examples, most of them are fine, given that the specific definition of each enum term is likely to be in the spec and the terms are relatively distinct (knowing something about the Web platform, I can guess what they means). CanPlayTypeResult stands out as less good, because maybe and probably both mean roughly the same thing with probably implying yes more strongly. Non-native speakers might not get it.

I cited ITS because it describes attributes related to translation that are commonly used in this space--but also because we took some of the features of ITS and incorporated them into HTML, notably the translate attribute, e.g.:

<p translate=yes>Do not translate HTML keywords like <span translate=no lang="zxx">span</span>.</p>

So my thinking was "if translate=[yes|no] then why not canTranslate()==[yes|no|downloadRequired]?"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
i18n-needs-resolution Issue the Internationalization Group has raised and looks for a response on.
Projects
None yet
Development

No branches or pull requests

2 participants