# Internationalisation (I18N) & Locale Files
This directory contains the files used by the library to store the text it uses. If you want to add support for a language, this is the
correct place. If you are adding text strings to a routine, you should use the ones here.
## Changing the language/locale used by the library.
There are several ways to change which locale file is used by the library. Use which ever one suits your needs best.
To keep the space used by the library to a minimum, all methods require the change to happen at compile time.
There is _no_ runtime option to change locales.
### Change `_IR_LOCALE_` in the `src/IRremoteESP8266.h` file.
In the [IRremoteESP8266.h](../IRremoteESP8266.h#L57-L59) file, find and locate the lines that look like:
```
#ifndef _IR_LOCALE_
#define _IR_LOCALE_ en-AU
#endif // _IR_LOCALE_
```
Change `en-AU` to the language & country that best suits your needs. e.g. `de-DE` for Germany/German.
### Use a compile-time build flag.
Use the compiler flag: `-D_IR_LOCALE_=en-AU` when compiling the library. Especially when compiling the `IRtext.cpp` file.
Change `en-AU` to a value which matches one of the file names in this directory. e.g. `de-DE` for Germany/German, which will use
the `de_DE.h` file.
### Use the appropriate pre-prepared build environment. _(PlatformIO only)_
If you examine the `platformio.ini` file located in the same directory as the example code you may find pre-setup compile environments
for the different supported locales.
Choose the appropriate one for you language by asking PlatformIO to build or upload using that environment.
e.g. See `IRrecvDumpV2`'s [platformio.ini](../../examples/IRrecvDumpV2/platformio.ini)
### Use a custom `build_flags`. _(PlatformIO only)_
Edit the `platformio.ini` file in the directory containing your example/source code.
Either in the default PlatformIO environment (`[env]`), or in which ever PlatformIO environment you using,
change or add the following line:
```
build_flags = -D_IR_LOCALE_=en-AU ; Or use which ever locale variable you want.
```
Every time you change that line, you should do a `pio clean` or choose the `clean` option from the build menu, to ensure a fresh copy
of `IRtext.o` is created.
## Adding support for a new locale/language.
Only [ASCII](https://en.wikipedia.org/wiki/ASCII#8-bit_codes)/[UTF-8](https://en.wikipedia.org/wiki/UTF-8) 8-bit characters are supported.
[Unicode](https://en.wikipedia.org/wiki/Unicode) is **not** supported. Unicode may work. It may not. It's just not supported.
i.e. If Arduino's `Serial.print()` can handle it, it will probably work.
### Copy/create a new locale file in this directory.
Copy [en-AU.h](en-AU.h) or which every is a closer fit for your language to `xx-YY.h` where `xx` is the [ISO code](https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes) for the language.
e.g. `en` is English. `de` is German etc. and `YY` is the ISO country code. e.g. `AU` is Australia.
Modify the comments and all `LOCALE_EN_AU_H_`s in the file to `LOCALE_XX_YY_H_` for your locale.
### Override any `#define` values that reside in `defaults.h`
Go through the [defaults.h](defaults.h) file, and find any `#define` lines that define a macro starting with `D_` that has text
that needs to change for your locale.
Copy or create a corresponding `#define D_STR_HELLOWORLD "Hello World"` in your `xx-YY.h` file, and translate the text appropriately
e.g. `#define D_STR_HELLOWORLD "Bonjour le monde"` (French)
Any values you `#define` in `xx-YY.h` will override the corresponding value in the [defaults.h](defaults.h) file.
### Supporting a dialect/regional varient of another _existing_ language/locale.
Similar to the previous step, if you only need to modify a small subset of the strings used in another locale file, then include the
other locale file and then make sure to `#undef` any strings that need to be (re-)changed.
See the [Swiss-German](de-CH.h) for an example of how to do this. i.e. It `#include "locale/de-DE.h"`s the German locale, and
redefines any strings that are not standard [German](de-DE.h).
## Adding new text strings to the library.
If you need to add an entirely new string to the library to support some feature etc. e.g. _"Widget"_.
You should first understand how the library tries to do this such that it is easy to support different languages for it.
1. Use a constant named `kWidgetStr` in the appropriate statement in the `.cpp` file.
2. Edit [IRtext.cpp](IRtext.cpp), and add the appropriate line for your new constant. e.g.
```
String kWidgetStr = D_STR_WIDGET;
```
The `kWidgetStr` variable will house the sole copy of the string for the entire library. This limits any duplication.
The `D_STR_WIDGET` macro will be what is targeted by the different language / locales files.
3. Edit [locale/defaults.h](defaults.h), and add the appropriate stanza for your new string. e.g.
```
#ifndef D_STR_WIDGET
#define D_STR_WIDGET "Turbo"
#endif // D_STR_WIDGET
```
4. _(Manual)_ Update [IRtext.h](../IRtext.h), and add the appropriate line for your new constant. e.g.
```
extern const String kWidgetStr;
```
For any file that `#include <IRtext.h>`s this file, it will tell it that the string is stored elsewhere,
and to look for it elsewhere at the object linking stage of the build. This is what makes the string be referenced from a central location.
4. _(Automatic)_ Run `tools/generate_irtext_h.sh` to update [IRtext.h](../IRtext.h).
In the [src/locale](../locale) directory. Run the `../../tools/generate_irtext_h.sh` command. It will update the file for you automatically.
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
智能开关平台,包含服务端、硬件端、安卓端和前端。智能开关的应用场景比较广泛,一般家里通电即可使用的设备都能搭配该模块,升级为网络版,进行联网控制。常见的就是智能开关、智能插座和智能灯,搭配土壤湿度传感器可以实现智能浇灌,搭配温湿度传感器可以监控温湿度,其他传感器例如:触控开关、雨滴探测、声音传感器、光敏传感器、烟雾传感器、火焰报警、人体感应等。智能开关目前支持的功能:远程控制;掉电记忆;触控开关;红外遥控;温湿度监测;本地控制;单双路继电器支持;智能配网(长按配置按钮进入);不联网模式(双击配置按钮切换)
资源推荐
资源详情
资源评论
收起资源包目录
kwswitch-master.zip (996个子文件)
app-release.aab 2.49MB
app-release.apk 2.68MB
run-tomcat.bat 266B
package.bat 153B
package.bat 141B
build.bat 109B
run-web.bat 99B
clean.bat 92B
CPPLINT.cfg 92B
CPPLINT.cfg 36B
nginx.conf 936B
ir_Daikin_test.cpp 125KB
ir_Daikin.cpp 122KB
IRac.cpp 84KB
ir_Hitachi_test.cpp 83KB
ir_Mitsubishi_test.cpp 73KB
IRac_test.cpp 72KB
ir_Samsung_test.cpp 66KB
ir_Mitsubishi.cpp 60KB
IRrecv.cpp 57KB
IRrecv_test.cpp 56KB
ir_Panasonic_test.cpp 52KB
ir_Hitachi.cpp 45KB
ir_Haier_test.cpp 40KB
ir_Fujitsu_test.cpp 39KB
IRutils.cpp 39KB
IRsend.cpp 36KB
ir_MitsubishiHeavy.cpp 36KB
ir_RC5_RC6_test.cpp 33KB
ir_Coolix_test.cpp 33KB
ir_Panasonic.cpp 31KB
ir_Toshiba_test.cpp 31KB
ir_Midea_test.cpp 30KB
ir_Haier.cpp 30KB
ir_Samsung.cpp 29KB
ir_MitsubishiHeavy_test.cpp 29KB
IRsend_test.cpp 29KB
ir_LG_test.cpp 29KB
ir_Sharp_test.cpp 28KB
IRutils_test.cpp 27KB
ir_Fujitsu.cpp 27KB
ir_Sony_test.cpp 25KB
ir_Whirlpool_test.cpp 23KB
ir_Gree_test.cpp 22KB
ir_Whirlpool.cpp 20KB
ir_Sharp.cpp 20KB
ir_Coolix.cpp 20KB
PubSubClient.cpp 20KB
ir_Goodweather_test.cpp 20KB
ir_Gree.cpp 19KB
ir_Kelvinator_test.cpp 19KB
ir_Kelvinator.cpp 18KB
ir_LG.cpp 18KB
ir_RC5_RC6.cpp 18KB
ir_Vestel.cpp 17KB
ir_Neoclima.cpp 17KB
ir_Vestel_test.cpp 16KB
ir_Pronto_test.cpp 15KB
ir_Midea.cpp 15KB
ir_Goodweather.cpp 15KB
ir_Tcl_test.cpp 14KB
ir_Neoclima_test.cpp 14KB
ir_Teco_test.cpp 14KB
ir_Dish_test.cpp 14KB
ir_Lasertag_test.cpp 14KB
ir_Aiwa_test.cpp 13KB
ir_Argo.cpp 12KB
ir_Toshiba.cpp 12KB
ir_Amcor_test.cpp 12KB
ir_NEC_test.cpp 12KB
ir_Denon_test.cpp 12KB
ir_Electra_test.cpp 12KB
ir_Electra.cpp 12KB
ir_JVC_test.cpp 11KB
ir_Tcl.cpp 11KB
kwswitch.cpp 10KB
ir_Teco.cpp 10KB
ir_Carrier_test.cpp 10KB
ir_Whynter_test.cpp 10KB
ir_Amcor.cpp 10KB
connect_spec.cpp 10KB
ir_Sanyo_test.cpp 10KB
ir_Trotec.cpp 9KB
ir_Airwell_test.cpp 9KB
ir_Sanyo.cpp 9KB
ir_RCMM_test.cpp 8KB
ir_Nikai_test.cpp 8KB
OneButton.cpp 8KB
ir_Sony.cpp 8KB
ir_Magiquest_test.cpp 7KB
IRtext.cpp 7KB
ir_Argo_test.cpp 7KB
receive_spec.cpp 7KB
ir_Lego_test.cpp 7KB
ir_Epson_test.cpp 6KB
ir_Symphony_test.cpp 6KB
ir_RCMM.cpp 6KB
ir_Pioneer_test.cpp 6KB
ir_GICable_test.cpp 6KB
ir_NEC.cpp 6KB
共 996 条
- 1
- 2
- 3
- 4
- 5
- 6
- 10
资源评论
m0_72731342
- 粉丝: 4
- 资源: 1829
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功