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

Add test token to check things about the language #88

Open
shaunix opened this issue Feb 26, 2021 · 1 comment
Open

Add test token to check things about the language #88

shaunix opened this issue Feb 26, 2021 · 1 comment
Milestone

Comments

@shaunix
Copy link
Contributor

shaunix commented Feb 26, 2021

Mallard Conditionals 1.0 defines the lang: test token prefix to check against the language of the page (or nearest ancestor with an xml:lang attribute). What I would like to do is check for aspects of a language or locale, without listing specific languages. The biggest thing is being able to check on directionality. I would like to detect RTL languages without writing a test expression like "lang:ar, lang:ckb, lang:fa, lang:he, lang:ug". Another example that might be useful is testing the primary script being used. such as Latin (Latn), Cyrillic (Cyrl), or Arabic (Arab). (Script tags: https://en.wikipedia.org/wiki/ISO_15924). These are both pieces of information that a processing tool can reasonably be expected to know about a supported locale.

I have three ideas on how this could be encoded, from most concise to least:

  1. Use a dash after lang: and a thing to test, like lang:-rtl or lang:-Cyrl.
  2. Use brand new prefixes, like dir:rtl or script:Cyrl.
  3. Use a sort of subprefix of lang:, like lang:dir:rtl or lang:script:Cyrl.

I like that (1) and (3) keep things lumped with language. I like that (2) and (3) are explicit about what's being tested. But I also like that (1) is super fast to write. I don't have a strong preference yet.

@shaunix shaunix added this to the if/1.1 milestone Feb 26, 2021
@shaunix
Copy link
Contributor Author

shaunix commented Feb 26, 2021

I meant to write my use case for testing directionality. I'm working on using more abstract diagrams in docs instead of actual screenshots. If these diagrams avoid words, they don't have to be translated. Except RTL locales would need a flipped diagram. So if the source pages can just provide two versions and use conditional processing, translators don't have to do any work. Something like this:

<media if:test="dir:ltr" src="image-for-ltr.svg" its:translate="no"/>
<media if:test="dir:rtl" src="image-for-rtl.svg" its:translate="no"/>

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

1 participant