lvgl / lv_i18n

Internationalization (i18n) for LVGL

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Suggestion] Rename from lv_i18n_language_pack to lv_i18n_lang_pack

seyyah opened this issue · comments

lv_i18n_init function argument type is lv_i18n_lang_pack_t but lv_i18n_language_pack variable name is used in the generated file (i18n.c). I suggest to use lv_i18n_lang_pack variable name for consistency/readability purpose.

int lv_i18n_init(const lv_i18n_lang_pack_t * langs);

In this case simple example'll be

#include "lv_i18n/lv_i18n.h"

/* Load translations & default locale (usually, done once) */
lv_i18n_init(lv_i18n_lang_pack);
lv_i18n_init(lv_i18n_language_pack);

IMHO this is more readable. It's used only once and no need to save 4 chars.

But it's not principal for me, and i'm ready to accept any result of majority voting.

@kisvegabor , @embeddedt , could you tell us your preferences?

For consistency, we really should use the same naming. So either:

  • lv_i18n_lang_pack_t lv_i18n_lang_pack;
  • lv_i18n_language_pack_t lv_i18n_language_pack;

is fine for me.

If questions is in consistency only, i'd prefer lv_i18n_language_pack_t lv_i18n_language_pack.

Can do it right not, if nobody objects.

We can use @kisvegabor' two styles at L114,

const lv_i18n_lang_pack_t lv_i18n_language_pack[] = {
  &en_gb_lang,
  ...
};

For minimal code change, we prefer to use lv_i18n_lang_pack_t lv_i18n_lang_pack;. Otherwise we change extra en_gb_lang's type,

static const lv_i18n_lang_t de_de_lang = {...}

📋 Reference

  1. https://github.com/littlevgl/lv_i18n/blob/master/src/lv_i18n.template.c#L114

Refered parts are:

  • internals
  • autogenerated

Their change costs nothing. IMHO the only thing, that does matter, is public API. In our case, this code in userspace:

#include "lv_i18n/lv_i18n.h"

lv_i18n_init(lv_i18n_language_pack);
// or lv_i18n_init(lv_i18n_lang_pack);

That's the only difference, visible from user's point of view. I think, public API should not be driven by implementation details if possible.

@puzrin your idea is suitable for me. So we may use

lv_i18n_init(lv_i18n_language_pack);