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

Fix Internationalization heading link to english #754

Closed
mu-hun opened this issue Feb 23, 2021 · 4 comments
Closed

Fix Internationalization heading link to english #754

mu-hun opened this issue Feb 23, 2021 · 4 comments

Comments

@mu-hun
Copy link
Contributor

mu-hun commented Feb 23, 2021

In Internationalization document, The Table of Content Link is muted to -.

This issue was reported from Japanese document (#646). You can reproduce from any language.

Screen Shot 2021-02-23 at 12 57 16 PM

In React doucment, Internationalization heading is wrapped to english

The document in the link above is maintain with english:

## React Element의 타입 지정하기 {#specifying-the-react-element-type}

It seems good to unify the links in English. Because there is no permerlink for each language like ko.preactjs.org.

@developit
Copy link
Member

@x86chi it's possible to permalink: https://preactjs.com/?lang=kr

@mu-hun
Copy link
Contributor Author

mu-hun commented Feb 23, 2021

From the next page, the lang query string will be hidden.

Navagate to "Differences to React" steps:

  1. https://preactjs.com/?lang=ko
  2. https://preactjs.com/guide/v10/differences-to-react

I think it is difficult to manually paste and share the query string.

@developit
Copy link
Member

@x86chi That's a fair point, yep! I had originally gone with the disappearing querystring because we didn't want to assume shared links should point to the same language - that way someone can share a link to documentation and it will detect.

Out of curiosity - did the docs automatically show in Korean for you when you first visited the site? We try to detect your language based on navigator.languages, but it's imperfect. Maybe that could be improved too.

I just re-read your original description and you're totally right about the heading identifiers - we're using a regular expression to convert non-alphanumeric characters to - and it doesn't account for non-english characters at all. We can definitely fix that.

@mu-hun
Copy link
Contributor Author

mu-hun commented Mar 6, 2021

did the docs automatically show in Korean for you when you first visited the site?

It works fine in modern browsers.

I had originally gone with the disappearing querystring because we didn't want to assume shared links should point to the same language

From a permerlink perspective, it seemed more semantic to always use a query string.

mu-hun added a commit to mu-hun/preact-www that referenced this issue Mar 6, 2021
```js
// Note: character range in regex is roughly "word characters including accented" (eg: bublé)
const id = text
  .toLowerCase()
  .replace(/[\s-]+/g, '-')
  .replace(/[^a-z0-9\u00C0-\u024F-]/g, '');
  // korean
  .replace(/[^가-힣]/g, '');
  // Japanese hiragana, katakana, kanji
  .replace(/[^\u3041-\u3096\u30A0-\u30FF\u2E80-\u2FD5]/g, '');
```

If want to keep existing intent, the above code might be more suitable.

Reference issue comment: preactjs#754 (comment)
mu-hun added a commit to mu-hun/preact-www that referenced this issue Mar 6, 2021
```js
// Note: character range in regex is roughly "word characters including accented" (eg: bublé)
const id = text
  // korean
  .replace(/[^가-힣]/g, '');
  // Japanese hiragana, katakana, kanji
  .replace(/[^\u3041-\u3096\u30A0-\u30FF\u2E80-\u2FD5]/g, '');
```

If want to keep existing intent, the above code might be more suitable.

Reference issue comment: preactjs#754 (comment)
mu-hun added a commit to mu-hun/preact-www that referenced this issue Mar 6, 2021
```js
// Note: character range in regex is roughly "word characters including accented" (eg: bublé)
const id = text
  // korean
  .replace(/[^가-힣]/g, '');
  // Japanese hiragana, katakana, kanji
  .replace(/[^\u3041-\u3096\u30A0-\u30FF\u2E80-\u2FD5]/g, '');
```

If want to keep existing intent, the above code might be more suitable.

But i haven't opinion yet, so I remove the one line that erased non-alphanumeric characters.

Reference issue comment: preactjs#754 (comment)
mu-hun added a commit to mu-hun/preact-www that referenced this issue Mar 6, 2021
```js
// Note: character range in regex is roughly "word characters including accented" (eg: bublé)
const id = text
  // korean, Japanese (hiragana)
  .replace(/[^가-힣\u3041-\u3096]/g, '');
```

If want to keep existing intent, the above code might be more suitable.

But i haven't opinion yet, so I remove the one line that erased non-alphanumeric characters.

Reference issue comment: preactjs#754 (comment)
developit added a commit that referenced this issue Mar 18, 2021
* Support non-alphanumeric characters in ToC

```js
// Note: character range in regex is roughly "word characters including accented" (eg: bublé)
const id = text
  // korean, Japanese (hiragana)
  .replace(/[^가-힣\u3041-\u3096]/g, '');
```

If want to keep existing intent, the above code might be more suitable.

But i haven't opinion yet, so I remove the one line that erased non-alphanumeric characters.

Reference issue comment: #754 (comment)

* Filter out programming/markdown characters only

Co-authored-by: Jason Miller <developit@users.noreply.github.com>
@mu-hun mu-hun closed this as completed Apr 17, 2021
jacob-jordan1 added a commit to jacob-jordan1/preact-www that referenced this issue May 22, 2022
* Support non-alphanumeric characters in ToC

```js
// Note: character range in regex is roughly "word characters including accented" (eg: bublé)
const id = text
  // korean, Japanese (hiragana)
  .replace(/[^가-힣\u3041-\u3096]/g, '');
```

If want to keep existing intent, the above code might be more suitable.

But i haven't opinion yet, so I remove the one line that erased non-alphanumeric characters.

Reference issue comment: preactjs/preact-www#754 (comment)

* Filter out programming/markdown characters only

Co-authored-by: Jason Miller <developit@users.noreply.github.com>
ryandel8834 added a commit to ryandel8834/Preact-WWW that referenced this issue Aug 14, 2022
* Support non-alphanumeric characters in ToC

```js
// Note: character range in regex is roughly "word characters including accented" (eg: bublé)
const id = text
  // korean, Japanese (hiragana)
  .replace(/[^가-힣\u3041-\u3096]/g, '');
```

If want to keep existing intent, the above code might be more suitable.

But i haven't opinion yet, so I remove the one line that erased non-alphanumeric characters.

Reference issue comment: preactjs/preact-www#754 (comment)

* Filter out programming/markdown characters only

Co-authored-by: Jason Miller <developit@users.noreply.github.com>
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

2 participants