多语言网站的设计模式?

发布于 2024-09-26 13:09:02 字数 269 浏览 4 评论 0原文

假设我正在设计一个网站,其中有英语、法语、西班牙语、德语和韩语(我没有,但让我们假装我有)。

我不能依赖谷歌翻译等服务,因为该网站的本质不是娱乐而是商业。假设我可以联系专业翻译人员,他们可以将上下文中的内容翻译成另一种语言,然后给我该文本。

通过网站提供多种语言的内容有哪些已知且简单的方法?

有很多选择,例如单独的页面、使用数据库等等......但我无法真正决定什么是最好的,概念如何扩展,需要考虑什么,以及如何处理缺失的翻译?

这方面有没有行之有效的做法?

Lets say I'm designing a website where we have English, French, Spanish, German, and Korea (I'm not, but lets pretend I am).

I cannot rely upon services such as google translate, as the nature of the website is not for entertainment but business. Lets say I have access to professional translators that can translate something in context to another language and give me that text.

What are some known and simple ways to serve up content over multiple languages with a website?

There's lots of options, such as separate pages, using a database, and so forth... but I can't really decide what's best, how the concept would scale, what needs to be considered, and how to deal with missing translations?

Are there any well-established practices for this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

往日情怀 2024-10-03 13:09:03

您所询问的广泛主题称为“国际化和本地化”(或简称 I18N 和 L10N)。需要记住的重要一点是,这不仅仅是翻译消息。网站国际化还有很多其他因素。

您需要的更明显的东西是:

  • 适用于所有语言字符的字符编码,而不仅仅是英语(这意味着数据库的所有内容都应该使用 UTF 编码)
  • 表示用户的 区域设置(即:Java 的 Locale 类)
  • 在该用户的区域设置中生成消息的常见模式(即:Spring 的 MessageSource

你需要的其他东西需要考虑:

  • 根据区域设置正确排序字符串 根据
  • 区域设置格式化日期
  • 始终显示用户所在时区的时间
  • 显示用户区域设置的距离测量值(即:英里与公里?)
  • 对于类似语言,以从右到左的方式布局网站希伯来语
  • 想想你如何使你的信息多元化。 String message = "Please fix the following error" + (errors.size() > 1 ? "s" : ""); 在国际化程序中不起作用。
  • 考虑一下当文本长度可能变化很大时如何布局网页..并且永远不要假设一个字符或多或少有一定的宽度(汉字中的单个字符可能比小写字母宽 8 倍) i')

我能找到的最佳资源是ICU 库的用户指南。如果您使用 Java,则可以使用该库。

希望这个答案是一个有用的开始!

The broad topic you're asking about is called "Internationalization and Localization" (or I18N and L10N for short). The important thing to remember is that it's not just about translating messages. There are many other things that go into internationalizing a website.

The more obvious things you will need are:

  • A character encoding that works for characters in all languages, not just English (This means everything down to the database should use UTF encoding)
  • Some way of representing the user's Locale (ie: Java's Locale class)
  • A common pattern for producing a message in that user's locale (ie: Spring's MessageSource

Other things you need to consider:

  • Properly sorting strings based on Locale
  • Formatting date based on locale
  • Always showing times in the user's time zone
  • Showing distance measurements for the user's locale (ie: Miles versus Kilometers?)
  • Laying out the website in right-to-left for languages like Hebrew
  • Think about how you pluralize your messages. String message = "Please fix the following error" + (errors.size() > 1 ? "s" : ""); just doesn't work in an internationalized program.
  • Think about how to lay out your web pages when the length of text may vary wildly.. and never assume that a character is more-or-less a certain width (a single character in Kanji might be 8 times wider than a lower case 'i')

The best resource I can find for this is the ICU library's User guide. If you use Java, this is the library to use.

Hopefully this answer is a helpful start!

静待花开 2024-10-03 13:09:03

Take a look at google's recommendations for Multi-regional and multilingual sites. Hope that information comes in handy. Best of luck.

a√萤火虫的光℡ 2024-10-03 13:09:03

完全同意@Michael D 和其他发布答案的开发人员的观点。虽然这个问题已经被接受,但我认为一个小选项,例如 :lang() 伪类也有助于创建多语言网站。 :lang() 伪类允许确定各种文档中的语言。

CSS 代码:

    q:lang(fr) {     /* Quotations for French */ 
     quotes: "\00AB" "\00BB"; 
    }

    q:lang(en) {
     quotes: "\201C" "\201D";    /* Quotations for English */ 
    }


HTML 代码:

 <html>
 <body>
 <pre>
     <p>Quote in French: <q lang="fr">То être ou ne pas être</q>.</p>
     <p>Quote in English: <q lang="en">То be or not to be</q>.</p>
 </pre>
 </body>
 </html>

输出将如下所示:

Quote in French language: << То être ou ne pas être >>.

Quote in English language: "То be or not to be".

请注意,我们谈论的是文档,而不是一段文本,因为它们执行复杂的格式设置。

Totally agree with @Michael D and other developers who posted their answers. Although the for this question is already accepted but I think one small option such as the :lang() pseudo class can be helpfull for createing multilingual sites as well. The :lang() pseudo class allows to determine the language in various documents.

CSS code:


    q:lang(fr) {     /* Quotations for French */ 
     quotes: "\00AB" "\00BB"; 
    }

    q:lang(en) {
     quotes: "\201C" "\201D";    /* Quotations for English */ 
    }


HTML code:

 <html>
 <body>
 <pre>
     <p>Quote in French: <q lang="fr">То être ou ne pas être</q>.</p>
     <p>Quote in English: <q lang="en">То be or not to be</q>.</p>
 </pre>
 </body>
 </html>

And the output will be like this:

Quote in French language: << То être ou ne pas être >>.

Quote in English language: "То be or not to be".

Please note that we are talking about documents, not a piece of text, as they perform complex formatting.

旧话新听 2024-10-03 13:09:03

我们在磁盘上有一组文件,其中包含给定小部件/模块/任何内容中的所有字符串,以及每种语言的单独文件,即:

foo.strings == generic (happens to be US english)
foo.fr.strings == french
foo.fr-CA.strings == canadian french 
foo.en-CA.strings == canadian english

根据客户端的 Accept-Language 标头,我们确定他想要哪种语言。

当第一次请求给定语言时,我们会访问文件系统来构建该语言的大字符串映射,然后将其缓存在内存中。如果 fr-CA 中没有定义给定的字符串,我们会将堆栈跳转到 fr,然后最终

动态生成通用页面,并根据用户的语言标头(以及其他)缓存每个 url 的生成版本。事物)。

希望有帮助

We have a set of files on disk that contain all the strings in a given widget/module/whatever, and separate files per language, i.e.:

foo.strings == generic (happens to be US english)
foo.fr.strings == french
foo.fr-CA.strings == canadian french 
foo.en-CA.strings == canadian english

Based on the client's Accept-Language header, we determine which language he wants.

When a given language is first requested, we hit the file system to build up the big string mapping for that language, then cache it in memory. If a given string isn't defined in fr-CA, we'll hop up the stack to fr, then eventually to the generic

Pages are generated dynamically and the generated version of each url is cached depending on the user's language headers (among other things).

Hope that helps

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文