简体   繁体   English

通过脚本安装/配置 Arduino IDE 首选项

[英]Install/configure Arduino IDE preferences via script

I created an ansible script that installs Arduino IDE together with an icon and Freedesktop compliant launcher file.我创建了一个 ansible 脚本来安装 Arduino IDE 以及一个图标和 Freedesktop 兼容的启动器文件。 This parts works very well.这部分工作得很好。

Now I want to preconfigure the IDE's language.现在我想预配置 IDE 的语言。 A lot of sites mention that preferences are stored in ~/.arduino15/preferences.txt .许多网站提到首选项存储在~/.arduino15/preferences.txt中。 Such a file does not exist on my computers.我的电脑上不存在这样的文件。 When I create it and add the language setting, it is completely ignored.当我创建它并添加语言设置时,它被完全忽略了。

Instead I found the file ~/.arduinoIDE/settings.json , but it seems to not contain any language settings.相反,我找到了文件~/.arduinoIDE/settings.json ,但它似乎不包含任何语言设置。

Then there is ~/.arduinoIDE/arduino-cli.yaml , and it has a locale key that is set to the value chosen in the UI.然后是~/.arduinoIDE/arduino-cli.yaml ,它有一个locale键,设置为在 UI 中选择的值。 However it seems not authorative for IDE startup.然而,它似乎不是 IDE 启动的权威。 Whatever I put in the file, the IDE will still used the language I configured in the IDE.无论我在文件中放入什么,IDE 仍将使用我在 IDE 中配置的语言。

Where does Arduino IDE store it's preferences that I can use to control the IDE's language on next startup? Arduino IDE 在哪里存储它的首选项,我可以在下次启动时使用它来控制 IDE 的语言?

I was able to drill down where the locale information is stored.我能够深入了解语言环境信息的存储位置。 Since Arduino-IDE 2.x (the Theja based one), preferences are kept in a leveldb at ~/.config/arduino-ide/Local Storage/leveldb .自 Arduino-IDE 2.x(基于Theja的版本)以来,首选项保存在~/.config/arduino-ide/Local Storage/leveldb中。

Following the hint from https://stackoverflow.com/a/53845549/4222206 and plyvel I was able to create the below python script, which will configure Arduino-IDE to run with the english locale (regardless of what you had configured in the UI before):根据https://stackoverflow.com/a/53845549/4222206plyvel的提示,我能够创建以下 python 脚本,它将配置 Arduino-IDE 以使用英语语言环境运行(无论您在用户界面之前):

import plyvel
db = plyvel.DB('~/.config/arduino-ide/Local Storage/leveldb')
db.put(b'_file://\x00\x01localeId', b'\x01en') 

So you may choose your language, eg French and just set the value to b'\x01fr' .因此,您可以选择您的语言,例如法语,并将值设置为b'\x01fr' Other languages seem to follow the same pattern.其他语言似乎遵循相同的模式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM