# 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.
没有合适的资源?快使用搜索试试~ 我知道了~
(源码)基于Arduino的通用红外遥控库.zip

共363个文件
hpp:134个
h:113个
cpp:106个

0 下载量 24 浏览量
2025-03-20
03:22:49
上传
评论
收藏 800KB ZIP 举报
温馨提示
# 基于Arduino的通用红外遥控库 ## 项目简介 本项目是一个基于Arduino平台的通用红外遥控库,旨在管理和复制电视、空调和投影仪的红外遥控器。通过使用ESP8266微控制器和相关的红外接收发送模块,用户可以轻松地管理多个设备的红外遥控信号。 ## 主要特性和功能 1. 多设备支持支持多种品牌和型号的电视、空调和投影仪的红外遥控。 2. 红外信号复制能够记录和重放红外遥控信号,实现遥控器的复制功能。 3. Web界面管理通过Web界面进行设备管理和红外信号的发送与接收。 4. 多种红外协议支持支持多种红外协议,如NEC、Panasonic、LG等。 5. 扩展性项目设计灵活,易于扩展新的红外协议和设备类型。 ## 安装使用步骤 1. 硬件准备 使用ESP8266微控制器(如WeMOS D1R2)。 连接红外接收模块(如KY022)和红外发送模块(如KY005)。 2. 软件准备 安装Arduino IDE。
资源推荐
资源详情
资源评论





























收起资源包目录





































































































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


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


最新资源
- 电气CAD制图常识.docx
- 量子技术中的学习与鲁棒控制
- 企业网站策划文案.docx
- TDSCDMA网络规划及优化.doc
- 51单片机课程方案设计书——智能电风扇.doc
- 计算机物联网技术在物流领域中的创新.docx
- 数据库原理与技术课程设计任务书.doc
- .net年下半年度广告媒介策略.ppt
- “大学生活馆”网站项目商业计划书.doc
- 大学计算机基础在信息时代下的教学研究.docx
- 学研赛并重的计算机类双创型人才培养模式探索.docx
- 自考电子商务与现代物流第六章真题汇总.doc
- 基于神经网络 LSTM 模型进行汇率预测的研究与应用 利用神经网络中的 LSTM 算法实现汇率走势预测的方法 采用神经网络 LSTM 技术构建汇率预测模型的方案设计 通过神经网络 LSTM 架构完成汇
- 电气工程自动化技术在电网建设中的应用分析.docx
- 工程项目管理系统解决-具体方案.doc
- NutzWk-Java资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



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