返回介绍

Translating Flarum

发布于 2021-11-04 22:44:46 字数 3103 浏览 983 评论 0 收藏 0

info

This documentation covers the technical structure of language packs. Read this article for information on how to start / contribute to a Flarum language pack.

Language packs should be their own extensions, with no other code / logic included.

The LanguagePack extender allows you to define that your extension is a language pack.

This extender has no setters. All you have to do is instantiate it, make sure you language pack is in the locale folder, and you're done!

Here's a quick example from Flarum English:


<?php


return new Flarum\Extend\LanguagePack();

The composer.json will also need some special values. It now needs a flarum-locale info object in extra, like flarum-extension. You can simply insert the following underneath the value of flarum-extension while remaining inside extra:


"flarum-locale": {
  "code": "en",
  "title": "English"
}

And that's it! It should work out of the box.

Translation files should go in the locale directory. Each file should be named EXTENSION_ID.yml, where EXTENSION_ID is the extension's ID.

The contents of the file should correspond to the extension's english translations, with the values translated in your language. See our internationalization docs for more information.

Flarum use the DayJS library to format and internationalize dates.

You can create a config.js file in the locale directory to configure date internationalization for your language.

The file should look like:


dayjs.locale('xx');

where the xx can be copied from https://unpkg.com/browse/[email protected]/locale/ for your language.

Alternatively, instead of using a compiled locale object, you can directly create one as per the dayjs documentation. This is slightly less efficient though.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文