w3c / secure-payment-confirmation

Secure Payment Confirmation (SPC)
https://w3c.github.io/secure-payment-confirmation/
Other
114 stars 40 forks source link

Localization topics to address #93

Closed ianbjacobs closed 2 years ago

ianbjacobs commented 3 years ago

Hi folks,

In light of our discussions with the Internationalization Working Group about Payment Request, I thought it would be useful to take note here of some topics that we should be sure to address in SPC.

We'll seek I18N review once a formal Working Draft; this is just to kick off discussion.

ianbjacobs commented 3 years ago

Here is a checklist from the I18N Working Group.

  1. [x] If the spec (or its implementation) contains any natural language text that will be read by a human (this includes error messages or other UI text, JSON strings, etc, etc),
  1. [ ] If the spec (or its implementation) allows content authors to produce typographically appealing text, either in its own right, or in association with graphics.

Not part of this API.

  1. [ ] If the spec (or its implementation) allows the user to point into text, creates text fragments, concatenates text, allows the user to select or step through text (using a cursor or other methods), etc.

Not part of this API.

  1. [ ] If the spec (or its implementation) allows searching or matching of text, including syntax and identifiers

Not part of this API.

  1. [ ] If the spec (or its implementation) sorts text

Not part of this API.

  1. [ ] If the spec (or its implementation) captures user input

Assuming this means "the user inputs some text" then not part of this API. There are "user gestures" to authenticate.

  1. [ ] If the spec (or its implementation) deals with time in any way that will be read by humans and/or crosses time zone boundaries

Not part of this API.

  1. [ ] If the spec (or its implementation) allows any character encoding other than UTF-8.

Not part of this API.

  1. [ ] If the spec (or its implementation) defines markup.

Not part of this API.

  1. [ ] If the spec (or its implementation) deals with names, addresses, time & date formats, etc

Not part of this API.

  1. [ ] If the spec (or its implementation) describes a format or data that is likely to need localization.

I don't think that is part of this API.

  1. [ ] If the spec (or its implementation) makes any reference to or relies on any cultural norms

Not part of this API.

It is possible that the underlying FIDO authentication iconography relates to cultural norms (e.g., display of a fingerprint to mean biometric authentication). SPC does not introduce anything on top of that.

aphillips commented 3 years ago

Don't overlook that PaymentCredentialInstrument dictionary contains a natural language string value (displayName) and thus requires language/direction metadata. While we're discussing backwards-compatible (and somewhat forced) in-string mechanisms for encoding these with webAuthn currently, SPC has no such backwards compatibility limitation AFAICT and should use metadata fields instead.

ianbjacobs commented 3 years ago

Hi @aphillips,

To confirm my understanding of the purpose of the lang/dir metadata information: to enable the browser to properly render in its modal window the information provided by the relying party.

ianbjacobs commented 3 years ago

@marcoscaceres, welcome your thoughts on this.

aphillips commented 3 years ago

To confirm my understanding of the purpose of the lang/dir metadata information: to enable the browser to properly render in its modal window the information provided by the relying party.

@ianbjacobs Exactly so.

ianbjacobs commented 3 years ago

@stephenmcgruer and @rsolomakhin, let's discuss!

ianbjacobs commented 3 years ago

See https://github.com/w3c/string-meta/issues/26

ianbjacobs commented 3 years ago

@rsolomakhin please mention what you'd like to see in more detail

ianbjacobs commented 3 years ago

@ve7jtb mentioned the following: although in general the SPC dialog will be displayed by the browser, it might also be displayed by some other entity (e.g., the OS). In those cases, to avoid error it may be even more important to have well-defined lang and dir as input rather than rely on browser context.

rsolomakhin commented 3 years ago

i18n folks: Could you please provide explicit examples where SPC displays the instrument name incorrectly? You have way more expertise here and I'd love to utilize it. For example:

Browser language: en-US
Page language: en-US.
Instrument display name: <insert name here>.
Instrument display name direction: LTR/RTL.
Instrument display name language-script code: <insert BCP47 here>.
Actual result: <insert screenshot of the incorrect rendering in here>.
Expected result: <describe or attach or what the correct rendering should look like>.

When we decide to add the l10n support, there're several possibilities of how to accomplish that:

  1. Add extra optional parameters:
    instrument: {
    displayName: 'Card****1234',
    language: 'en-US',  // Optional.
    direction: 'ltr',  // Optional.
    icon: 'https://icons.example/card.png',
    }
  1. Make displayName accept a very limited subset of HTML:
    instrument: {
    displayName: '<span lang="en-US" dir="ltr">Card****1234</span>',
    icon: 'https://icons.example/card.png',
    }
  1. Make displayName accept a JSON string with value, direction, and language fields.
    instrument: {
    displayName: '{"language": "en-US", "direction": "ltr", "value": "Card****1234"}',
    icon: 'https://icons.example/card.png',
    }
  1. Utilize @marcoscaceres's new Localizable strings:
    instrument: {
    displayName: {language: 'en-US', direction: 'ltr', value: 'Card****1234'},
    icon: 'https://icons.example/card.png',
    }

    (If I understand how it works correctly.)


Option 4 is what I'm leaning toward because of the more sane feature detection and ability to back-port pre-existing string fields that are used fordisplayName.

Integrators and implementers: Please help me to understand your organization's preferences!

aphillips commented 3 years ago

@rsolomakhin Could you have a look at these documents, which might answer some of your questions:

https://w3c.github.io/i18n-drafts/articles/lang-bidi-use-cases/ https://w3c.github.io/string-meta/

You may also want to look at JSON-LD for various JSON-based mechanisms, cf. https://www.w3.org/TR/json-ld/#string-internationalization

stephenmcgruer commented 3 years ago

To give a direction for the upcoming TPAC discussion on this issue: I propose we make displayName a union of String and a Localizable structure, as a backwards-compatible version of option 4. (It would also be great if i18n group gets to a point where Localizable is not something that we have to define before we do this.)

rsolomakhin commented 2 years ago

Aside from Localizable, can the i18n folks please provide guidance on defining alt-text for images that are passed into APIs? For example, should the alt-text have a language associated with them for the sake of the screen reader? Should the alt-text have a direction?

ianbjacobs commented 2 years ago

See related resource in development: https://github.com/aphillips/i18n-discuss/blob/gh-pages/explainers/string-meta-explainer.md

aphillips commented 2 years ago

@ianbjacobs: the official copy is more up-to-date: https://github.com/w3c/i18n-discuss/blob/gh-pages/explainers/string-meta-explainer.md

aphillips commented 2 years ago

@rsolomakhin I18N believes that any human-readable (natural language) string data should have language and direction metadata associated with it, either directly or, failing that, at the document level. APIs should be able to store, forward, and process this information for consumption. Page authors can then use the data to build as rich (or poor) a customer experience as they want.

The HTML img tag's alt attribute doesn't have a way to express the language or control the base direction of the associated string, although, I suppoed in the case of an image tag one might use the lang and dir attributes of the tag itself? Other language-bearing attributes in HTML can't use that workaround/hack, of course. This is a long-standing (and lamented) situation with HTML.

However, APIs might expose the text in other ways than just producing an alt attribute and the information might be consumed by (for example) the screen reader in that way. In the case of an image alt that's pretty speculative, of course. But the page author might use a different approach, such as enclosing the img in a figure and using the figcaption element instead of using alt.

rsolomakhin commented 2 years ago

Thank you for the update, @aphillips!

ianbjacobs commented 2 years ago

See https://github.com/w3ctag/design-reviews/issues/716

ianbjacobs commented 2 years ago

We added payeeName to the specification; we'll want to be able to localize that value as well.

ianbjacobs commented 2 years ago

@aphillips, @r12a, @xfq, we've not heard much news about generalized support for localizable strings in ECMAScript or in a "standalone spec" that could be referenced from SPC, WebAuthn, and other specs that involve JSON being displayed in browser UX.

I've just created pull request #192 based on language that we used in Payment Request API: that lang and dir information can be taken from the document context and used within the browser's native UX. This does not address downstream usage of the data, but I suspect for real downstream interop we would want ECMAScript level support in any case.

Please let us know whether this text would satisfy the I18N WG for version 1 of the specification, or what changes you would find helpful. Thank you!

ianbjacobs commented 2 years ago

@aphillips, @r12a, @xfq, it would be great to hear from you. Could we discuss no later than TPAC? Thanks!

ianbjacobs commented 2 years ago

Closing this issue based on more recent and more specific I18N issues #205 and and #209, as well as discussion with @aphillips during TPAC.

For a more recent I18N checklist, see #202.

Regarding "localized error messages", SPC does not itself define any error messages.