yari icon indicating copy to clipboard operation
yari copied to clipboard

Validate language code in translated content links

Open nschonni opened this issue 3 years ago • 1 comments

Summary

Yari does a good job today of flagging when an internal link uses a language code link that doesn't exist (yet) and will fall back to the en-US version. Where it could be enhanced is to flag when an invalid language code is used in an internal link.

URL

https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleTimeString

Reproduction steps

  1. Macro is using {{page('zh-US/docs/JavaScript/Reference/Global_Objects/DateTimeFormat','Parameters')}} with an invalid language code
  2. Other ones i've come across:
    • /en/ & /zh/ under specified language code
    • /ja-US/

Expected behavior

If the link or macro path isn't in an allow list of supported languages, Yari should raise a warning. External links like MSDN that use language codes would be ignored.

Actual behavior

Warnings are raised that it will fall back to /en-US/ version, even if there is a correct localized document.

Device

Desktop

Browser

Firefox

Browser version

Stable

Operating system

Windows

Screenshot

No response

Anything else?

No response

Validations

nschonni avatar Aug 18 '22 02:08 nschonni

We would accept a community PR that extends build/flaws/broken-links.js to emit a flaw for /{locale}/docs links where {locale} is not a supported locale. 👍

caugner avatar Aug 18 '22 17:08 caugner

It looks like this is resolved either with content tooling, or with our new rari build system: https://github.com/mdn/translated-content/pull/26396

caugner avatar Mar 14 '25 19:03 caugner

It looks like this is resolved either with content tooling, or with our new rari build system: mdn/translated-content#26396

The script is provided here: https://github.com/mdn/translated-content/blob/main/scripts/check-url-locale.js

yin1999 avatar Mar 16 '25 01:03 yin1999