WeblateOrg / WeblateOrg/weblate
C-Header/source based translation files
- Dominant language
- Python
- Stars
- 6.1k
- Forks
- 1.4k
- Avg merge
- 9h 53m
- Merged PRs (30d)
- 395
Description
### Describe the problem
There are several projects which are targeting to embedded devices or microcontrollers, and they are unable to use any existing translation systems, and they have them implemented just as a set of C headers/sources that contains declarations of key=value arrays, or macros, etc.
### Solution brainstorm
It would be cool to support some kind of C-header/source based translation files in same manner as regular translations. And for the safety purposes, ensure these header/sources contains ONLY the data of transation without unnecessary code. So it will be easier to produce translations for projects that are targeting to embedded devices and microcontrollers where all the translations will be hardcoded into firmware.
I do have some possible abstract formats of such translation file formats:
- Key=value array:
```c
/* File 1 */
const char *const g_lang_en[][2] =
{
{"hello", "Hello my friend!"},
{"callme", "Please call me!"},
{"tea", "Let's drink more tea?"} /* <-- At files for C89/C90 last comma must absent, like in JSON. */
};
```
```c
/* File 2 */
const char *const g_lang_ru[][2] =
{
{"hello", "Привет, мой друг!"},
{"callme", "Пожалуйста, позвони мне!"},
{"tea", "Давай пить больше чая?"}
};
```
- Similar Key=value array but for C++ (std::map / std::unordered_map):
```cpp
/* File 1 */
std::map g_lang_en =
{
{"hello", "Hello my friend!"},
{"callme", "Please call me!"},
{"tea", "Let's drink more tea?"},
};
```
```cpp
/* File 2 */
std::map g_lang_ru =
{
{"hello", "Привет, мой друг!"},
{"callme", "Пожалуйста, позвони мне!"},
{"tea", "Давай пить больше чая?"},
};
```
- Function that assigns global variables:
```c
/* File 1 */
#include "lang.h"
void initEnglish()
{
g_strings.hello = "Hello my friend!";
g_strings.callme = "Please call me!";
g_strings.tea = "Let's drink more tea?";
};
```
```c
/* File 2 */
#include "lang.h"
void initRussian()
{
g_strings.hello = "Привет, мой друг!";
g_strings.callme = "Пожалуйста, позвони мне!";
g_strings.tea = "Давай пить больше чая?";
};
```
### Describe alternatives you have considered
Just use workarounds that converts one of known formats like JSON/CSV/etc. into C headers during build or something also that might complicate the build by adding of extra actions and requiring to have the host-run compiler for a cross-compiling project.
### Screenshots
_No response_
### Additional context
It's fine to support SOME small set of such formats, no need to support every super-unique one. Let's project developers tune their code so it will be compatible to one of such formats as well.
Contributor guide
Research direction
The issue names no files, tests, or entry points. First identify the existing regular-translation support and decide which small C or C++ data-only format(s) are in scope. Done would mean the selected format(s) are supported safely without allowing unnecessary code.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, cpp
- Domain
- localization
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100