带有 i18n 的 Fiber
这是一个关于如何使用 nicksnyder/go-i18n 包将您的 Fiber 应用程序翻译成多种语言的快速示例。
演示
- 运行 Fiber 应用程序;
- 打开
http://127.0.0.1:3000/?unread=1
并查看
Hello Bob
I have 1 unread email.
Bob has 1 unread email.
- 接着,访问
http://127.0.0.1:3000/?unread=4
并查看您消息的复数形式
Hello Bob
I have 4 unread emails.
Bob has 4 unread emails.
- 好的。尝试其他语言的翻译,只需在 URL 中添加查询参数
&lang=es
(或&lang=ru
)
Hola Bob
Tengo 4 correos electrónicos no leídos
Bob tiene 4 correos electrónicos no leídos