多语言网站的最佳做法是什么?

时间:2021-04-19 20:04:05

I want to make a multi-language site, such that all or almost all pages will be available in 2 or more translations. What are the best practices to follow?

我想创建一个多语言网站,以便所有或几乎所有页面都可以在2个或更多翻译中使用。有哪些最佳做法?

For example, I consider these language selection mechanisms:

例如,我考虑这些语言选择机制:

  1. Cookie-based selection of the preferred language.
  2. 基于Cookie的首选语言选择。

  3. Based on Accept-Language header if the cookie is not set.
  4. 如果未设置cookie,则基于Accept-Language标头。

  5. Based on GeoIP otherwise (probably).
  6. 否则基于GeoIP(可能)。

Is there anything else?

还有别的事吗?

How should different translations be served?

如何提供不同的翻译?

  1. as LANG.example.com/page
  2. as example.com/LANG/page
  3. as example.com/page?hl=LANG
  4. ...
  5. any of the above with a redirect to example.com/page? (It seems to be discouraged)
  6. 以上任何一个重定向到example.com/page? (似乎气馁)

How to ensure that all the translations are properly indexed?

如何确保所有翻译都正确编入索引?

  1. Sitemaps with all pages + correct Content-Language header are enough?
  2. 所有页面+正确的内容 - 语言标题的站点地图都足够了吗?

What is the best way to let the users know there are other translations, but do not distract them?

让用户知道有其他翻译的最佳方法是什么,但不要分散他们的注意力?

  1. list available languages in the header/footer/sidebar (like Wikipedia)
  2. 列出页眉/页脚/侧边栏中的可用语言(如*)

  3. put “Choose a language” selector next to the content
  4. 在内容旁边放置“选择语言”选择器

What is the best policy to deal with missing/outdated translations?

处理遗失/过时翻译的最佳政策是什么?

  1. do not display missing pages at all or display a page in a different language?
  2. 根本不显示缺页或用其他语言显示页面?

  3. display old translation, old translation with a warning or a page in a different language?
  4. 显示旧翻译,带有警告的旧翻译或使用其他语言的页面?

What else should I take into account? What should I do and what I definitely should not?

还有什么我应该考虑的?我该怎么做以及我绝对不应该做什么?

3 个解决方案

#1


In addition to @Quassnoi's answers ensure that you standard RFC 4646 language identifiers (e.g. EN-US, DE-AT); you may already be aware of this. The CLDR project is an excellent repository of internationalization data (the Supplemental Data is really useful).

除了@Quassnoi的答案之外,还要确保您使用标准的RFC 4646语言标识符(例如EN-US,DE-AT);你可能已经意识到了这一点。 CLDR项目是国际化数据的优秀存储库(补充数据非常有用)。

If a translation of a specific page is not available, use a language fallback mechanism back to the neutral language; for example "DE-AT", "DE", "" (neutral, e.g. "EN").

如果特定页面的翻译不可用,请使用语言回退机制返回中性语言;例如“DE-AT”,“DE”,“”(中性,例如“EN”)。

Most recent browsers and the underlying operating systems will correctly show all of the characters required for a locale selector list if the page is encoded correctly (I'd recommend all pages being UTF-8). Ensure that the locale list contains both the native and current-language names to allow both native and non-native speakers to view the specified translations, e.g. "Deutsch (German)" if the current locale is EN-*.

如果页面编码正确,最新的浏览器和底层操作系统将正确显示区域设置选择器列表所需的所有字符(我建议所有页面都是UTF-8)。确保语言环境列表包含本机语言和当前语言名称,以允许本机和非母语人员查看指定的翻译,例如“Deutsch(德语)”如果当前的语言环境是EN- *。

A lot of sites use a flag icon to show the current locale, but this is more relevant to the location and some people may be offended if you show only a dominant flag (e.g. the US or UK flag for English).

许多网站使用标志图标来显示当前的区域设置,但这与位置更相关,如果您只显示主导旗帜(例如英国的美国或英国旗帜),则某些人可能会被冒犯。

It may be worthwhile to have a more visible (semi-graphical) locale selector on the home page if no locale cookie has been submitted, using a combination of GeoIP and Accept-Language to determine the default locale choice.

如果没有提交区域设置cookie,则可以在主页上使用更可见(半图形)的区域设置选择器,使用GeoIP和Accept-Language的组合来确定默认的区域设置选择。

Semi-related: if your users are in located in different time zones include a zone preference in their account profile for displaying time values in their local time. And store all time stamps using UTC.

半相关:如果您的用户位于不同的时区,则在其帐户配置文件中包含区域首选项,以便在当地时间显示时间值。并使用UTC存储所有时间戳。

#2


Make the decision whether you need support for languages that require double byte characters early on (Chinese, Japanese, Korean, etc), Unicode is the preferable choice. It can be tedious to change later, especially if you have a database that doesn't use unicode.

决定是否需要支持早期需要双字节字符的语言(中文,日文,韩文等),Unicode是首选。稍后更改可能会很繁琐,尤其是如果您有一个不使用unicode的数据库。

#3


  1. Cookie-based selection of the preferred language.
  2. 基于Cookie的首选语言选择。

  3. Based on Accept-Language header if the cookie is not set.
  4. 如果未设置cookie,则基于Accept-Language标头。

These two you should support.

这两个你应该支持。

Put a big english banner at the top of your page that reads This page in English.

在页面顶部放一个大英文横幅,用英文阅读本页面。

as example.com/LANG/page

This is the best choice.

这是最好的选择。

LANG.example.com isn't good for autocomplete, and the question marks look ugly.

LANG.example.com不适合自动完成,问号看起来很难看。

list available languages in the header/footer/sidebar (like Wikipedia)

列出页眉/页脚/侧边栏中的可用语言(如*)

Choose a language dropbox is confusing, as it is not intelligible being written in a wrong foreign language and spoils overall impression being written in English.

选择一种语言保管箱会让人感到困惑,因为它不能用错误的外语写成,并且会损害用英语写的整体印象。

And you always tend to make the error selecting the language you don't even have fonts for leaving yourself on a page full of question marks.

并且你总是倾向于选择你甚至没有字体的语言错误选择让你自己留在充满问号的页面上。

display old translation with a warning

显示带有警告的旧翻译

You know there is something you can read and get the point, but for the details you'd better get a dictionary and read it in English.

你知道有些东西你可以阅读并得到重点,但是对于细节你最好得到一本字典并用英文阅读。

#1


In addition to @Quassnoi's answers ensure that you standard RFC 4646 language identifiers (e.g. EN-US, DE-AT); you may already be aware of this. The CLDR project is an excellent repository of internationalization data (the Supplemental Data is really useful).

除了@Quassnoi的答案之外,还要确保您使用标准的RFC 4646语言标识符(例如EN-US,DE-AT);你可能已经意识到了这一点。 CLDR项目是国际化数据的优秀存储库(补充数据非常有用)。

If a translation of a specific page is not available, use a language fallback mechanism back to the neutral language; for example "DE-AT", "DE", "" (neutral, e.g. "EN").

如果特定页面的翻译不可用,请使用语言回退机制返回中性语言;例如“DE-AT”,“DE”,“”(中性,例如“EN”)。

Most recent browsers and the underlying operating systems will correctly show all of the characters required for a locale selector list if the page is encoded correctly (I'd recommend all pages being UTF-8). Ensure that the locale list contains both the native and current-language names to allow both native and non-native speakers to view the specified translations, e.g. "Deutsch (German)" if the current locale is EN-*.

如果页面编码正确,最新的浏览器和底层操作系统将正确显示区域设置选择器列表所需的所有字符(我建议所有页面都是UTF-8)。确保语言环境列表包含本机语言和当前语言名称,以允许本机和非母语人员查看指定的翻译,例如“Deutsch(德语)”如果当前的语言环境是EN- *。

A lot of sites use a flag icon to show the current locale, but this is more relevant to the location and some people may be offended if you show only a dominant flag (e.g. the US or UK flag for English).

许多网站使用标志图标来显示当前的区域设置,但这与位置更相关,如果您只显示主导旗帜(例如英国的美国或英国旗帜),则某些人可能会被冒犯。

It may be worthwhile to have a more visible (semi-graphical) locale selector on the home page if no locale cookie has been submitted, using a combination of GeoIP and Accept-Language to determine the default locale choice.

如果没有提交区域设置cookie,则可以在主页上使用更可见(半图形)的区域设置选择器,使用GeoIP和Accept-Language的组合来确定默认的区域设置选择。

Semi-related: if your users are in located in different time zones include a zone preference in their account profile for displaying time values in their local time. And store all time stamps using UTC.

半相关:如果您的用户位于不同的时区,则在其帐户配置文件中包含区域首选项,以便在当地时间显示时间值。并使用UTC存储所有时间戳。

#2


Make the decision whether you need support for languages that require double byte characters early on (Chinese, Japanese, Korean, etc), Unicode is the preferable choice. It can be tedious to change later, especially if you have a database that doesn't use unicode.

决定是否需要支持早期需要双字节字符的语言(中文,日文,韩文等),Unicode是首选。稍后更改可能会很繁琐,尤其是如果您有一个不使用unicode的数据库。

#3


  1. Cookie-based selection of the preferred language.
  2. 基于Cookie的首选语言选择。

  3. Based on Accept-Language header if the cookie is not set.
  4. 如果未设置cookie,则基于Accept-Language标头。

These two you should support.

这两个你应该支持。

Put a big english banner at the top of your page that reads This page in English.

在页面顶部放一个大英文横幅,用英文阅读本页面。

as example.com/LANG/page

This is the best choice.

这是最好的选择。

LANG.example.com isn't good for autocomplete, and the question marks look ugly.

LANG.example.com不适合自动完成,问号看起来很难看。

list available languages in the header/footer/sidebar (like Wikipedia)

列出页眉/页脚/侧边栏中的可用语言(如*)

Choose a language dropbox is confusing, as it is not intelligible being written in a wrong foreign language and spoils overall impression being written in English.

选择一种语言保管箱会让人感到困惑,因为它不能用错误的外语写成,并且会损害用英语写的整体印象。

And you always tend to make the error selecting the language you don't even have fonts for leaving yourself on a page full of question marks.

并且你总是倾向于选择你甚至没有字体的语言错误选择让你自己留在充满问号的页面上。

display old translation with a warning

显示带有警告的旧翻译

You know there is something you can read and get the point, but for the details you'd better get a dictionary and read it in English.

你知道有些东西你可以阅读并得到重点,但是对于细节你最好得到一本字典并用英文阅读。