# 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:
```c++
#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](https://github.com/crankyoldgit/IRremoteESP8266/blob/master/src/locale/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](https://github.com/crankyoldgit/IRremoteESP8266/blob/master/src/locale/defaults.h) file.
### Supporting a dialect/regional variant 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](https://github.com/crankyoldgit/IRremoteESP8266/blob/master/src/locale/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](https://github.com/crankyoldgit/IRremoteESP8266/blob/master/src/locale/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.
```c++
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](https://github.com/crankyoldgit/IRremoteESP8266/blob/master/src/locale/defaults.h), and add the appropriate stanza for your new string. e.g.
```c++
#ifndef D_STR_WIDGET
#define D_STR_WIDGET "Turbo"
#endif // D_STR_WIDGET
```
4. _(Manual)_ Update [IRtext.h](https://github.com/crankyoldgit/IRremoteESP8266/blob/master/src/IRtext.h), and add the appropriate line for your new constant. e.g.
```c++
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](https://github.com/crankyoldgit/IRremoteESP8266/blob/master/src/IRtext.h).
In the [src/locale](https://github.com/crankyoldgit/IRremoteESP8266/blob/master/src/locale/) directory. Run the `../../tools/generate_irtext_h.sh` command. It will update the file for you automatically.
没有合适的资源?快使用搜索试试~ 我知道了~
(源码)基于ESP8266的IRremoteESP8266红外遥控库.zip

共339个文件
cpp:170个
h:73个
ini:29个

1 下载量 45 浏览量
2025-03-17
04:09:16
上传
评论
收藏 1015KB ZIP 举报
温馨提示
# 基于ESP8266的IRremoteESP8266红外遥控库 ## 项目简介 IRremoteESP8266是一个用于ESP8266和ESP32平台的红外遥控库,支持发送和接收多种红外协议。该库允许用户通过红外信号控制各种设备,如空调、电视、音响等。它提供了丰富的API和示例代码,方便开发者快速集成和使用。 ## 项目的主要特性和功能 1. 多协议支持支持多种红外协议,包括NEC、Sony、LG、Panasonic、Samsung、Whynter等。 2. 发送和接收功能支持发送和接收红外信号,用户可以通过代码控制设备或解析接收到的信号。 3. 空调控制支持多种空调品牌的控制,如Daikin、Mitsubishi、Gree、Haier等。 4. 定时器和校验和提供定时器和校验和功能,确保信号的准确性和完整性。 5. 状态管理支持空调状态的管理,包括温度、模式、风速、摆动等设置。
资源推荐
资源详情
资源评论




















收起资源包目录





































































































共 339 条
- 1
- 2
- 3
- 4
资源评论


t0_54coder
- 粉丝: 4554
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


最新资源
- 改善交流伺服系统脉冲接口抗干扰能力(00001).doc
- 单片机和USB接口技术高速数据采集系统设计方案.doc
- GeekDesk-C#资源
- 大数据下互联网广告精准投放策略探讨.docx
- 浅议中职院校计算机课程实施翻转课堂的保障条件.docx
- 大数据产业新高地成就贵安精彩.docx
- gis中属性数据的输入和管理.ppt
- 数字图像处理降噪滤波大作业.doc
- 大数据、信息化时代电子档案管理的安全问题研究.docx
- watermark-js-plus-JavaScript资源
- (源码)基于Hyperf框架和Vue的微信服务系统.zip
- 电力信息化管理中存在的问题及对策解析.docx
- 网络环境下企业会计信息披露研究.docx
- 人工智能从前沿概念走进青少年实际生活.docx
- 计算机多媒体技术的应用现状及其发展前景分析.docx
- 农业电子商务平台建设现状附存在问题.doc
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



安全验证
文档复制为VIP权益,开通VIP直接复制
