指南
- 介绍
- Contribute
- 部署
- 管理
- 高级
内部文档
扩展
- Main 核心概念
- 参考指南
- 进阶指南
- 更新指南
Translating Flarum
This documentation covers the technical structure of language packs. Read this article for information on how to start / contribute to a Flarum language pack.
Declaring a 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
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.
DayJS Translations
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论