speced / speced/respec

Generating figure link text by language

Open
#2,339 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
806
Forks
434
Avg merge
1d 21h
Merged PRs (30d)
32

Description

When generating links to figures, respec creates link text such as "Figure 15" for english documents. If the html tag has lang="ja", it generates "図15".

However, in the multilingual documents mentioned above this doesn't work well. You end up with english everywhere because on the initial load the html lang attribute is set to en, eg.

The following are the basic elements of a page format. Figure 11 illustrates an example of a page format in vertical writing mode).

基本となる組体裁の主な設計要素としては,次がある(縦組の例をFigure 11に示す).

Rather than only checking the setting of the html tag, it would be better to check the language of the text being converted, so that the outcome would be:

The following are the basic elements of a page format. Figure 11 illustrates an example of a page format in vertical writing mode).

基本となる組体裁の主な設計要素としては,次がある(縦組の例を図11に示す).

However, there is another issue with the (large) multilingual docs currently being used by i18n folks: since each item of japanese text has its-locale-filter-list="ja" already, lang attributes are currently added by scripting after the page loads (in order to make life easier for content authors).

There appear to be the following possible solutions for jlreq, clreq & klreq docs:

  1. add lang attributes to the source text everwhere there are its-locale-filter-list attributes (rather than apply those by scripting), and require authors to add lang tags in future, then use those lang tags to determine whether the link text needs to be localised
  2. use its-locale-filter-list attributes in the algorithm to determine whether to use english or localised link text. (There is a small twist in that clreq currently uses data-lang rather than its-locale-filter-list, but we can change that.)

The second approach may actually be appropriate for multilingual docs, since that attribute indicates the location of the localised version of a string, however, for the case where we produce a monolingual Japanese document (for example) with no need for its- attributes, we'd need to rely on lang tags. So maybe (1) is the better approach(?)

Thoughts?

cc @xfq @himorin @kidayasuo

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the figure-link generation behavior affecting the jlreq, clreq, and klreq specifications, and compare how lang, its-locale-filter-list, and data-lang are applied. Define and test a language-selection approach that produces localized figure link text in multilingual documents while preserving the existing behavior for monolingual documents.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
documentation, internationalization
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.