Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: cleanup translations #3082

Closed
wants to merge 2 commits into from
Closed

Conversation

mha1
Copy link
Contributor

@mha1 mha1 commented Jan 22, 2023

The workshop is open ...

@mha1 mha1 changed the title Main author @ulfhedlund - initial empty commit Chore: cleanup translations Jan 22, 2023
@mha1 mha1 marked this pull request as draft January 22, 2023 19:18
@ulfhedlund
Copy link
Contributor

@HThuren: I am honestly not quite sure what we have signed up to try and do :)

My understanding was that we should check whether there are unused strings in the firmware translation files, and if so suggest to have them removed. But only after testing that no firmware builds fail, of course.

We would first need to find those unused strings, for example by searching for each and all of the TR_* strings in all appropriate files (*.cpp, *.h, except translations.cpp, translations.h and the various language files themselves, e.g. se.h/da.h etc) and if a TR string is not found in any of those files have it noted. I am sure that can be done in many different ways.

In other words: how do we find those TR_strings that are not included in any of the radio/src/*.cpp or *.h files?
Any ideas?

@mha1
Copy link
Contributor Author

mha1 commented Jan 24, 2023

Hey guys,

I see different ways of cleaning up in the order of easy to a little difficult:

1. missing translations
Scan the language files for English words in xx.h files other than en.h. They probably are untranslated defaults and may need translation

2. Search for obsolete defines
The way translations find their way into the final firmware built for a specific language look roughly like this:

  • Every xx.h file defines macros in the form of #define MACRONAME value, e.g. #define TR_NO "Nej"
  • translations.cpp defines the variables which are finally used by the firmware code, e.g. const char STR_NO[] = TR_NO;. At compile time the C pre-processor will use the macros to replace TR_NO with the value defined in yy.h with yy being the language that is requested by the -DTRANSLATIONS=yy build directive. After the pre-processor has finished its work the variable definition will finally be const char STR_NO[] = "Nej"; for a Danish build or const char STR_NO[] = "No"; for an English build.
  • translations.h just contains extern declarations of the variables, e.g. extern const char STR_NO[]; to allow the firmware code to use the variables by including translations.h without having to declare variables on its own and let the linker resolve the memory addresses of the variables.

So if you want to find out if the TR_NO define is used in the code search for STR_NO. If you only find it in xx.h files and translations.cpp/.h then it is not used in firmware code

3. Look for duplicate definition
Try looking for "Navn" in da.h files. You'll get those hits:
#define TR_NAME "Navn"
#define TR_EXPONAME TR("Navn", "Line navn")
#define TR_PHASES_HEADERS_NAME "Navn"
#define TR_LIMITS_HEADERS_NAME "Navn"
#define TR_GVAR_HEADERS_NAME "Navn"

If you are sure all the definitions have the same meaning this could be made single source by:
#define TR_NAME "Navn"
#define TR_EXPONAME TR(TR_NAME, "Line navn")
#define TR_PHASES_HEADERS_NAME TR_NAME
#define TR_LIMITS_HEADERS_NAME TR_NAME
#define TR_GVAR_HEADERS_NAME TR_NAME

Or even better do a follow up search for e.g. where TR_PHASES_HEADERS_NAME is used (hint: translations.h) and replace it there with TR_NAME directly. This allows yo to delete the line #define TR_PHASES_HEADERS_NAME "Navn" entirely.

@ulfhedlund
Copy link
Contributor

Thanks @mha1. We will do this bit by bit and it may take a while but we will give it a shot and see how it goes.

@mha1
Copy link
Contributor Author

mha1 commented Jan 24, 2023

No hurry, no pressure, this PR is marked as Draft - work in progress.

@philmoz
Copy link
Collaborator

philmoz commented Jan 24, 2023

STR_GASSUIT_AVG_FLOW In untranslated.h; but also in all language files except fi.h
TRIM_SWITCH_CHAR missing in cz.h de.h fi.h and fr.h, defined but not used in se.h
TR_RXFREQUENCY missing in cz.h de.h fr.h nl.h; but not used anywhere in the code

@HThuren
Copy link
Contributor

HThuren commented Jan 24, 2023

But we don't always have the connection between TR_defines and STR_defines[] !

@mha1
Copy link
Contributor Author

mha1 commented Jan 24, 2023

do you have an example?

@HThuren
Copy link
Contributor

HThuren commented Jan 24, 2023

None of
// Voice in native language
#define TR_VOICE_ENGLISH "English"
#define TR_VOICE_CHINESE "Chinese"
#define TR_VOICE_CZECH "Czech"
#define TR_VOICE_DANISH "Danish"
#define TR_VOICE_DEUTSCH "German"
#define TR_VOICE_DUTCH "Dutch"
#define TR_VOICE_ESPANOL "Spanish"
#define TR_VOICE_FRANCAIS "French"
#define TR_VOICE_HUNGARIAN "Hungarian"
#define TR_VOICE_ITALIANO "Italian"
#define TR_VOICE_POLISH "Polish"
#define TR_VOICE_PORTUGUES "Portuguese"
#define TR_VOICE_RUSSIAN "Russian"
#define TR_VOICE_SLOVAK "Slovak"
#define TR_VOICE_SWEDISH "Swedish"
#define TR_VOICE_TAIWANESE "Taiwanese"

@philmoz
Copy link
Collaborator

philmoz commented Jan 25, 2023

TR_THROTTLE_START is spelled TH_THROTTLE_START in en.h

@philmoz
Copy link
Collaborator

philmoz commented Jan 25, 2023

The entries below are NOT in en.h; but are defined in one or more of the other language files as listed:

INDENT - fi.h
INDENT_WIDTH - fi.h
LEN2_VTEMPLATES - de.h fi.h
LEN_INDENT - fi.h
LEN_SPORT_UPDATE_POWER_MODES - nl.h
TR_A3_A4 - cz.h fi.h fr.h se.h
TR_A3_A4_MIN - cz.h fi.h fr.h se.h
TR_ASPD_MAX - cz.h fi.h fr.h se.h
TR_CUST_FUNC_CUST_LABEL - se.h
TR_DAY - cn.h tw.h
TR_GYRO - se.h
TR_GYROS - nl.h se.h
TR_GYRO_LABEL - se.h
TR_GYRO_MAX - se.h
TR_GYRO_OFFSET - se.h
TR_INVERT_ROTARY - se.h
TR_MENUSETUP - es.h
TR_MODEL_CATEGORIES - se.h
TR_MONTH - cn.h tw.h
TR_PROTO - cn.h tw.h
TR_RAS - cz.h fi.h fr.h se.h
TR_RX_BATT - cz.h fi.h fr.h se.h
TR_SDCARDVERSIONWARN - se.h
TR_TELEM_RESERVE - cz.h fi.h fr.h se.h
TR_TELEM_RSSI_RX - cz.h cz.h fi.h fi.h fr.h fr.h se.h se.h
TR_TELEM_TIME - cz.h fi.h fr.h se.h
TR_TELEM_TIMERS - cz.h fi.h fr.h se.h
TR_TMR1LATMINUS - cz.h fr.h se.h
TR_VLCD - cz.h de.h fi.h fr.h se.h
TR_YEAR - cn.h tw.h

@pfeerick
Copy link
Member

pfeerick commented Jan 25, 2023

TR_GYRO and related are no longer used... replace with TR_IMU
TR_MODEL_CATEGORIES and TR_INVERT_ROTARY are also leftovers
TR_SDCARDVERSIONWARN may never be used again

@mha1
Copy link
Contributor Author

mha1 commented Jan 25, 2023

Lots of work as it seems.

The very first input (thanks @philmoz) shows we need a common understanding of how working with language dependent stuff should be done. TR_GASSUIT_AVG_FLOW is part of how and where telemetry sensors are named. Most of the telemetry sensor defines are in untranslated.h starting at line 158. But there are also telemetry sensors defined (and directly used in code) in language specific files. Furthermore there are duplicate definitions for the same sensor name, eg STR_RSSI "RSSI" in language specific files and TR_SENSOR_RSSI "RSSI" untranslated.h. Both are used in code (STR_RSSI and STR_SENSOR_RSSI). It is also worth to note that none of the telemetry sensor definitions in the language specific files are actually translated.

My options proposal for a cleanup:

  1. If the option to ever wanting to translate telemetry sensor names is to be kept alive:
  • all telemetry sensor definitions go to the language specific files
  • naming convention for telemetry sensor defines is TR_SENSOR_<sensor> in the language specific files
  • all TR_SENSOR_ defines have variable definitions STR_SENSOR_in translations.cpp and extern declarations in translations.h
  • STR_SENSOR_ variables are used in code
  1. If we want to continue with the current situation that telemetry sensors are all in English, i.e. remain untranslated:
  • all telemetry sensor definitions go to untranslated.h.
  • naming convention for telemetry sensor defines is STR_SENSOR_<sensor>
  • all telemetry sensor variable definitions in translations.cpp and extern declarations in translations.h are to be deleted
  • STR_SENSOR_ defines are used in code directly.

Note: both options require some editorial updates in /src/telemetry/.cpp files. From a flash usage and performance perspective I believe both options should have the same footprint. From a cleanup point of view option 1 is much more work than option 2.

The main question here is: do we want to ever translate telemetry sensor names?

Any thoughts?

@HThuren
Copy link
Contributor

HThuren commented Jan 25, 2023

Well, in danish ex 'Alt' are translated, so I'm afraid it's diffrent when to translate sensors.
I think it's a wrong way to go, to remove the the possibility to translate.
Really don't see the need to remove, but only defines not in use anyware.

@mha1
Copy link
Contributor Author

mha1 commented Jan 25, 2023

Do you mean #define STR_ALT "Alt" line 1195 in da.h?

@HThuren
Copy link
Contributor

HThuren commented Jan 25, 2023

I think of:
#define TR_ALTITUDE INDENT "Højde"
#define TR_ALTSENSOR "Højde sensor"
not in line 1195, but still really don't see the need to remove, but only defines not in use anywere.

@mha1
Copy link
Contributor Author

mha1 commented Jan 25, 2023

I am not advocating for/against removal, just trying to analyze potential cleanups. The two definitions you mentioned are not part of what I was talking about. The two are part of the UI code and need to be in the language specific xx.h files. I was talking about the telemetry sensor names e.g. as they appear in the list of discovered telemetry sensors. Most of the names you'll find in this list are defined in untranslated.h. But some others are defined in xx.h. Have a look at the block line 1186 (STR_VFR) to line 1339 (STR_FLOW) in da.h. You'll find an identical block in all other xx.h files. All having the same English definitions. So telemetry sensor names have never been translated so far.

@pfeerick would translated sensor names jeopardize the effort to move away from index based telemetry to name based telemetry?

Check out the column names:
image

@mha1
Copy link
Contributor Author

mha1 commented Jan 25, 2023

Sorry, I have to correct myself. da.h does translate at least one telemetry sensor name #define STR_SPEED "Fart" vs "Spd ". Actually a funny one :-)

@philmoz
Copy link
Collaborator

philmoz commented Jan 25, 2023

In addition to the TR_VOICE_? entries mentioned earlier, the following are defined in en.h; but do not appear to be used anywhere in the radio code:

TR_ACCEL
TR_ACHANNEL
TR_AILDIRECTION
TR_BAR
TR_BG
TR_CHR_HOUR
TR_CHR_INPUT
TR_CHR_LONG
TR_CHR_SHORT
TR_CHR_TOGGLE
TR_COLDIRECTION
TR_CURRENT
TR_DEL_BUTTON
TR_DIFFERENTIAL
TR_DISABLE_POPUP
TR_ELEDIRECTION
TR_ENABLE_POPUP
TR_EXPO
TR_FAS_OFFSET
TR_FREQUENCY
TR_GVAR_HEADERS_FM0
TR_GVAR_HEADERS_FM1
TR_GVAR_HEADERS_FM2
TR_GVAR_HEADERS_FM3
TR_GVAR_HEADERS_FM4
TR_GVAR_HEADERS_FM5
TR_GVAR_HEADERS_FM6
TR_GVAR_HEADERS_FM7
TR_GVAR_HEADERS_FM8
TR_GVAR_HEADERS_NAME
TR_INVERT_THR
TR_LATITUDE
TR_LIMIT
TR_LIMITS_HEADERS_CURVE
TR_LIMITS_HEADERS_MAX
TR_LIMITS_HEADERS_MIN
TR_LIMITS_HEADERS_NAME
TR_LIMITS_HEADERS_PPMCENTER
TR_LIMITS_HEADERS_SUBTRIM
TR_LIMITS_HEADERS_SUBTRIMMODE
TR_LONGITUDE
TR_LSW_HEADERS_ANDSW
TR_LSW_HEADERS_DELAY
TR_LSW_HEADERS_DURATION
TR_LSW_HEADERS_FUNCTION
TR_LSW_HEADERS_V1
TR_LSW_HEADERS_V2
TR_MAX_PLURAL2
TR_MENUDATEANDTIME
TR_MINRSSI
TR_MIN_PLURAL2
TR_MIX
TR_MODS_FORBIDDEN
TR_PCBREV_ERROR
TR_PERSISTENT_MAH
TR_PHASES_HEADERS_AIL_TRIM
TR_PHASES_HEADERS_CH5_TRIM
TR_PHASES_HEADERS_CH6_TRIM
TR_PHASES_HEADERS_ELE_TRIM
TR_PHASES_HEADERS_FAD_IN
TR_PHASES_HEADERS_FAD_OUT
TR_PHASES_HEADERS_NAME
TR_PHASES_HEADERS_RUD_TRIM
TR_PHASES_HEADERS_SW
TR_PHASES_HEADERS_THT_TRIM
TR_PINMAPSET
TR_PLAY_BOTH
TR_RFPOWER_AFHDS2
TR_ROTARY_ENCODERS
TR_ROTENC_SWITCHES
TR_RXBATT
TR_SAVE_MODEL
TR_SERVOS_KO
TR_SERVOS_OK
TR_SHUTDOWN
TR_SYNCMENU
TR_TEMPLATE_CLEAR_MIXES
TR_TEMPLATE_DELTA
TR_TEMPLATE_ECCPM
TR_TEMPLATE_HELI
TR_TEMPLATE_SERVO_TEST
TR_TEMPLATE_SIMPLE_4CH
TR_TEMPLATE_STICKY_TCUT
TR_TEMPLATE_VTAIL
TR_TXnRX
TR_UNLOCKED
TR_USE_PLURAL2
TR_USE_PLURAL2_SPECIAL_CASE
TR_USE_SINGULAR_IN_PLURAL
TR_USRDATA

@mha1
Copy link
Contributor Author

mha1 commented Jan 25, 2023

It's a mix.

Most are really not used

Some are used by further defines which are used

#define CHR_HOUR   TR_CHR_HOUR
#define CHR_INPUT  TR_CHR_INPUT

Some are used by further defines which are also never used
#define TR_GVAR_HEADERS { HINT(TR_GVAR_HEADERS_FM0), HINT(TR_GVAR_HEADERS_FM1), HINT(TR_GVAR_HEADERS_FM2), HINT(TR_GVAR_HEADERS_FM3), HINT(TR_GVAR_HEADERS_FM4), HINT(TR_GVAR_HEADERS_FM5), HINT(TR_GVAR_HEADERS_FM6), HINT(TR_GVAR_HEADERS_FM7), HINT(TR_GVAR_HEADERS_FM8)

And a few are used to declare constexpr int's in translations.h. (should be done in translations.cpp and externed in translations.h)

constexpr int g_max_plural2 = TR_MAX_PLURAL2;
constexpr int g_min_plural2 = TR_MIN_PLURAL2;
constexpr int g_use_singular_in_plural = TR_USE_SINGULAR_IN_PLURAL;
constexpr int g_use_plural2_special_case = TR_USE_PLURAL2_SPECIAL_CASE;
constexpr int g_use_plural2 = TR_USE_PLURAL2;

@mha1
Copy link
Contributor Author

mha1 commented Jan 25, 2023

@HThuren

@HThuren No rule without exception :-). TR_VOICE_ defines are used in tts_xx.cpp. They should really be STR_VOICE_ definitions. I couldn't find any other TR_ in other .cpp/.h files other than the translation related files

// Voice in native language
#define TR_VOICE_ENGLISH "English"
#define TR_VOICE_CHINESE "Chinese"
#define TR_VOICE_CZECH "Czech"
#define TR_VOICE_DANISH "Danish"
#define TR_VOICE_DEUTSCH "German"
#define TR_VOICE_DUTCH "Dutch"
#define TR_VOICE_ESPANOL "Spanish"
#define TR_VOICE_FRANCAIS "French"
#define TR_VOICE_HUNGARIAN "Hungarian"
#define TR_VOICE_ITALIANO "Italian"
#define TR_VOICE_POLISH "Polish"
#define TR_VOICE_PORTUGUES "Portuguese"
#define TR_VOICE_RUSSIAN "Russian"
#define TR_VOICE_SLOVAK "Slovak"
#define TR_VOICE_SWEDISH "Swedish"
#define TR_VOICE_TAIWANESE "Taiwanese"

@HThuren
Copy link
Contributor

HThuren commented Jan 25, 2023

@HThuren

@HThuren No rule without exception :-). TR_VOICE_ defines are used in tts_xx.cpp. They should really be STR_VOICE_ definitions. I couldn't find any other TR_ in other .cpp/.h files other than the translation related files

// Voice in native language
#define TR_VOICE_ENGLISH "English"
#define TR_VOICE_CHINESE "Chinese"
#define TR_VOICE_CZECH "Czech"
#define TR_VOICE_DANISH "Danish"
#define TR_VOICE_DEUTSCH "German"
#define TR_VOICE_DUTCH "Dutch"
#define TR_VOICE_ESPANOL "Spanish"
#define TR_VOICE_FRANCAIS "French"
#define TR_VOICE_HUNGARIAN "Hungarian"
#define TR_VOICE_ITALIANO "Italian"
#define TR_VOICE_POLISH "Polish"
#define TR_VOICE_PORTUGUES "Portuguese"
#define TR_VOICE_RUSSIAN "Russian"
#define TR_VOICE_SLOVAK "Slovak"
#define TR_VOICE_SWEDISH "Swedish"
#define TR_VOICE_TAIWANESE "Taiwanese"

I made the PR with the naitive languge name, will look into (in another PR) make the STR definition.

@HThuren
Copy link
Contributor

HThuren commented Jan 25, 2023

I am not advocating for/against removal, just trying to analyze potential cleanups. The two definitions you mentioned are not part of what I was talking about. The two are part of the UI code and need to be in the language specific xx.h files. I was talking about the telemetry sensor names e.g. as they appear in the list of discovered telemetry sensors. Most of the names you'll find in this list are defined in untranslated.h. But some others are defined in xx.h. Have a look at the block line 1186 (STR_VFR) to line 1339 (STR_FLOW) in da.h. You'll find an identical block in all other xx.h files. All having the same English definitions. So telemetry sensor names have never been translated so far.

@pfeerick would translated sensor names jeopardize the effort to move away from index based telemetry to name based telemetry?

Check out the column names: image

Right, I think this to be translated one day, the ones who releate to other transated terms, ie. STR_ALT, STR_GALT, TR_CURR, TR_ASPD, TR_GSPD, etc
Others are already translated
#define STR_PITCH "Højd"
#define STR_ROLL "Kræn"
#define STR_YAW "Side"
#define STR_THROTTLE "Gas"

@mha1
Copy link
Contributor Author

mha1 commented Jan 25, 2023

@HThuren There is actually duplicate definitions for Roll/Pitch/Yaw/throttle. Search for example for STR_ROLL in xx.h and STR_SENSOR_ROLL in translated.h. The ones used in code is STR_SENSOR_ROLL/PITCH/YAW/THROTTLE. It looks despite your translation efforts those sensors are used non-translated.

STR_SPEED (the one with the funny translation) has no duplicate and is only used in a single MPM Protocol (Multiplex MLink mlink.cpp). From briefly scanning other xx.h files I'd be inclined to say you might be the only one having translated some sensor names so far. In reality only one is used in code (STR_SPEED).

The question is will there be more language wide effort to translate sensor names. But in any case I really don't like the duplicate definitions. They are misleading.

@mha1
Copy link
Contributor Author

mha1 commented Jan 25, 2023

@HThuren I have compared the telemetry sensor name definition sections of en.h (reference) to all other language files. Here's the differences:

DA
#define STR_PITCH "H├╕jd"				// not used in code
#define STR_ROLL "Kræn"				// not used in code
#define STR_YAW "Side"					// not used code
#define STR_THROTTLE "Gas"			// only used in Spektrum telemetry
#define STR_SPEED "Fart"				// only used in MLink telemetry

FI
#define STR_GASSUIT_AVG_FLOW "GAFl"         // misses this unused one

FR
#define STR_BATT "BtRx"				// instead of "RxBT" (used in 5 telemetry protocol drivers)

IT
#define STR_GPSDATETIME "Data"			//instead of "Date" (used in 5 telemetry protocol drivers)

Currently there are about 164 telemetry sensor names defined. Telemetry sensor names are limited to 4 characters and are mostly short names or abbreviations, not words you'd find in a dictionary. This and the fact that up to now only very limited use was made of translations for sensor names makes me believe there is no strong requirement to have 160+ nearly identical definitions in the 15 xx.h files. As a huge fan of the single source principle I propose a change to implement a single source but still allowing for overrides in xx.h.

An override in da.h would look like this:
#undef STR_SENSOR_SPEED // STR_SENSOR_SPEED is defined in the single source as "Spd"
#define STR_SENSOR SPEED "Fart" // override the definition to "Fart" for Danish language

I created a branch on my fork for the telemetry sensor names cleanup:

  • all telemetry sensor name definitions in one place (untranslated.h)
  • all telemetry sensor name definitions follow the naming convention STR_SENSOR_
  • eliminated one redundant definition
  • editorial updates to telemetry protocols code to reflect the naming convention changes
  • re-introduced translations in da.h (STR_SENSOR_THROTTLE and STR_SENSOR_SPEED)
  • re-introduced translation in it.h (STR_SENSOR_GPSDATETIME)
  • re-introduced translation for fr.h ( STR_SENSOR_BATT)
  • saved 160 Bytes of flash

Please have a gracious look at https://github.com/mha1/edgetx/tree/choreCleanupTelemetryNamesDefs and if possible run the language test builds. My local tests and package firmware run was successful for all radios.

@mha1
Copy link
Contributor Author

mha1 commented Jan 25, 2023

@philmoz @pfeerick Here's my feedback. Most of your input should be safe to remove. It'll be a lot of work to do manually. Is there some wizard out there that can to a shell script to delete entries (lines) based on a black list? I can compile the black list.

The entries below are NOT in en.h; but are defined in one or more of the other language files as listed:

INDENT - fi.h
INDENT_WIDTH - fi.h
LEN_INDENT - fi.h

I think this should be removed as this is already defined in translations.h

#if defined(COLORLCD)
#define BUTTON(x) x
#define INDENT
#else
#define BUTTON(x) "[" x "]"
#define INDENT "\001"
#define LEN_INDENT 1
#define INDENT_WIDTH (FW/2)
#endif

LEN2_VTEMPLATES - de.h fi.h
This is strange because it is used (only) in radio\src\gui\128x64\model_templates.cpp but there is no define for LEN2_VTEMPLATES (and others used in this compilation unit). Looking at the log of a TX12 compile I'd say this is a dead file. If I am right the LEN2_VTEMPLATES can be removed

TR_GYRO - se.h
TR_GYROS - nl.h se.h
TR_GYRO_LABEL - se.h
TR_GYRO_MAX - se.h
TR_GYRO_OFFSET - se.h

As per @pfeerick should be removed. IMU strings are used now

TR_MONTH - cn.h tw.h
This is used in flysky.cpp in CN and TW language configuration

#if defined(TRANSLATIONS_CN) || defined(TRANSLATIONS_TW)
sprintf(str, "%d" TR_MONTH "%d", t.tm_mon + 1, t.tm_mday);

TR_THROTTLE_START is spelled TH_THROTTLE_START in en.h
Yes, needs update

LEN_SPORT_UPDATE_POWER_MODES - nl.h
TR_A3_A4 - cz.h fi.h fr.h se.h
TR_A3_A4_MIN - cz.h fi.h fr.h se.h
TR_ASPD_MAX - cz.h fi.h fr.h se.h
TR_CUST_FUNC_CUST_LABEL - se.h
TR_DAY - cn.h tw.h
TR_INVERT_ROTARY - se.h
TR_MENUSETUP - es.h
TR_MODEL_CATEGORIES - se.h
TR_PROTO - cn.h tw.h
TR_RAS - cz.h fi.h fr.h se.h
TR_RX_BATT - cz.h fi.h fr.h se.h
TR_SDCARDVERSIONWARN - se.h
TR_TELEM_RESERVE - cz.h fi.h fr.h se.h
TR_TELEM_RSSI_RX - cz.h cz.h fi.h fi.h fr.h fr.h se.h se.h
TR_TELEM_TIME - cz.h fi.h fr.h se.h
TR_TELEM_TIMERS - cz.h fi.h fr.h se.h
TR_TMR1LATMINUS - cz.h fr.h se.h
TR_VLCD - cz.h de.h fi.h fr.h se.h
TR_YEAR - cn.h tw.h

Should be removed

In addition to the TR_VOICE_? entries mentioned earlier, the following are defined in en.h; but do not appear to be used anywhere in the radio code:

TR_MIN_PLURAL2
TR_MAX_PLURAL2
TR_USE_PLURAL2
TR_USE_PLURAL2_SPECIAL_CASE
TR_USE_SINGULAR_IN_PLURAL

They are used through const int declarations in translations.h. The declarations are used in code
constexpr int g_max_plural2 = TR_MAX_PLURAL2;
constexpr int g_min_plural2 = TR_MIN_PLURAL2;
constexpr int g_use_singular_in_plural = TR_USE_SINGULAR_IN_PLURAL;
constexpr int g_use_plural2_special_case = TR_USE_PLURAL2_SPECIAL_CASE;
constexpr int g_use_plural2 = TR_USE_PLURAL2;

TR_CHR_HOUR
is used in 128x64 lcd.cpp via translations.h Should be simplified
#define CHR_HOUR TR_CHR_HOUR
#define CHR_INPUT TR_CHR_INPUT

TR_GVAR_HEADERS_FM0
TR_GVAR_HEADERS_FM1
TR_GVAR_HEADERS_FM2
TR_GVAR_HEADERS_FM3
TR_GVAR_HEADERS_FM4
TR_GVAR_HEADERS_FM5
TR_GVAR_HEADERS_FM6
TR_GVAR_HEADERS_FM7
TR_GVAR_HEADERS_FM8

They are used to form the list TR_GVAR_HEADERS which is not used. Can all go

TR_LIMITS_HEADERS_CURVE
TR_LIMITS_HEADERS_MAX
TR_LIMITS_HEADERS_MIN
TR_LIMITS_HEADERS_NAME
TR_LIMITS_HEADERS_PPMCENTER
TR_LIMITS_HEADERS_SUBTRIM
TR_LIMITS_HEADERS_SUBTRIMMODE

They are used to form the list TR_LIMITS_HEADERS which is not used. Can all go

TR_LSW_HEADERS_ANDSW
TR_LSW_HEADERS_DELAY
TR_LSW_HEADERS_DURATION
TR_LSW_HEADERS_FUNCTION
TR_LSW_HEADERS_V1
TR_LSW_HEADERS_V2

They are used to form the list TR_LSW_HEADERS which is not used. Can all go.

TR_PHASES_HEADERS_AIL_TRIM
TR_PHASES_HEADERS_CH5_TRIM
TR_PHASES_HEADERS_CH6_TRIM
TR_PHASES_HEADERS_ELE_TRIM
TR_PHASES_HEADERS_FAD_IN
TR_PHASES_HEADERS_FAD_OUT
TR_PHASES_HEADERS_NAME
TR_PHASES_HEADERS_RUD_TRIM
TR_PHASES_HEADERS_SW
TR_PHASES_HEADERS_THT_TRIM

They are used to form the list TR_PHASES_HEADERS which is not used. Can all go.

TR_ACCEL
TR_ACHANNEL
TR_AILDIRECTION
TR_BAR
TR_BG
TR_CHR_LONG
TR_CHR_SHORT
TR_CHR_TOGGLE
TR_COLDIRECTION
TR_CURRENT
TR_DEL_BUTTON
TR_DIFFERENTIAL
TR_DISABLE_POPUP
TR_ELEDIRECTION
TR_ENABLE_POPUP
TR_EXPO
TR_FAS_OFFSET
TR_FREQUENCY
TR_GVAR_HEADERS_NAME
TR_INVERT_THR
TR_LATITUDE
TR_LIMIT
TR_LONGITUDE
TR_MENUDATEANDTIME
TR_MINRSSI
TR_MIX
TR_MODS_FORBIDDEN
TR_PCBREV_ERROR
TR_PERSISTENT_MAH
TR_PINMAPSET
TR_PLAY_BOTH
TR_RFPOWER_AFHDS2
TR_ROTARY_ENCODERS
TR_ROTENC_SWITCHES
TR_RXBATT
TR_SAVE_MODEL
TR_SERVOS_KO
TR_SERVOS_OK
TR_SHUTDOWN
TR_SYNCMENU
TR_TEMPLATE_CLEAR_MIXES
TR_TEMPLATE_DELTA
TR_TEMPLATE_ECCPM
TR_TEMPLATE_HELI
TR_TEMPLATE_SERVO_TEST
TR_TEMPLATE_SIMPLE_4CH
TR_TEMPLATE_STICKY_TCUT
TR_TEMPLATE_VTAIL
TR_TXnRX
TR_UNLOCKED
TR_USRDATA

I checked also, not used in code, should be removed

@philmoz
Copy link
Collaborator

philmoz commented Jan 25, 2023

Here's my feedback. Most of your input should be safe to remove. It'll be a lot of work to do manually. Is there some wizard out there that can to a shell script to delete entries (lines) based on a black list? I can compile the black list.

Should be easy enough to script (I created a script to generate the initial list).

@mha1
Copy link
Contributor Author

mha1 commented Jan 25, 2023

I'll try - will call for help eventually

@ulfhedlund
Copy link
Contributor

Wow, seems that the translations really were in need of some TLC from you developers. A lot of old stuff that can be removed. Great work!

@mha1
Copy link
Contributor Author

mha1 commented Jan 26, 2023

@philmoz No call for help, worked out a script to do the removals

@pfeerick While scanning for obsolete definitions I found radio\src\gui\128x64\model_templates.cpp is not used in any radio firmware build. Shouldn't this file be removed from the source tree?

I have updated my fork with all discussed and some additional removals of obsolete definitions and translations. "Run tests and package firmware" completed with no errors, EN and DA companion builds are working without problems. Woohoo, and about 280 Bytes of flash memory saved.

@ulfhedlund I kindly ask you to run your language builds using https://github.com/mha1/edgetx/tree/choreCleanupTelemetryNamesDefs

@HThuren All sensor name definitions are now in one place (untranslated.h) but it is still possible to override sensor names with language specific translations in xx.h. It is pretty straight forward. Undefine the sensor name definition and define a new one. I have done this to da.h, it.h and fr.h as those are the only ones having translated very very few sensor names. Here's the part in da.h to show the concept:

#undef  STR_SENSOR_THROTTLE
#define STR_SENSOR_THROTTLE            "Gas"
#undef  STR_SENSOR_SPEED
#define STR_SENSOR_SPEED               "Fart"

Having all sensor name definitions in one place (untranslated.h) is not stopping translations. If translators want to override sensor names they can do it using the above concept.

To show the concept is working I built a Danish language TX16s Companion overriding GSpd with "Fart" using the above concept:
image

@HThuren
Copy link
Contributor

HThuren commented Jan 26, 2023

@philmoz No call for help, worked out a script to do the removals

@pfeerick While scanning for obsolete definitions I found radio\src\gui\128x64\model_templates.cpp is not used in any radio firmware build. Shouldn't this file be removed from the source tree?

I have updated my fork with all discussed and some additional removals of obsolete definitions and translations. "Run tests and package firmware" completed with no errors, EN and DA companion builds are working without problems. Woohoo, and about 280 Bytes of flash memory saved.

@ulfhedlund I kindly ask you to run your language builds using https://github.com/mha1/edgetx/tree/choreCleanupTelemetryNamesDefs

@HThuren All sensor name definitions are now in one place (untranslated.h) but it is still possible to override sensor names with language specific translations in xx.h. It is pretty straight forward. Undefine the sensor name definition and define a new one. I have done this to da.h, it.h and fr.h as those are the only ones having translated very very few sensor names. Here's the part in da.h to show the concept:

#undef  STR_SENSOR_THROTTLE
#define STR_SENSOR_THROTTLE            "Gas"
#undef  STR_SENSOR_SPEED
#define STR_SENSOR_SPEED               "Fart"

Having all sensor name definitions in one place (untranslated.h) is not stopping translations. If translators want to override sensor names they can do it using the above concept.

Great job, I think it will do, and all the cleanup make the xx.h more easy to cover. :-)

@HThuren
Copy link
Contributor

HThuren commented Jan 26, 2023

I do the compile all models and x10s all languages with your
choreCleanupTelemetryNamesDefs branch

@mha1
Copy link
Contributor Author

mha1 commented Jan 26, 2023

@HThuren Great, thanks! I built all radio models but doing it again won't hurt.

@HThuren
Copy link
Contributor

HThuren commented Jan 27, 2023

All compile done - all language for x10, all models EN and DA, good to go :-)

@pfeerick
Copy link
Member

While scanning for obsolete definitions I found radio\src\gui\128x64\model_templates.cpp is not used in any radio firmware build. Shouldn't this file be removed from the source tree?

Possibly. The templates screen was something I found quite useful on the Turnigy 9x/9XR/9XR Pro, but for some reason it doesn't seem to have been used on the other radios, and is something I actually wanted to see re-instated ... but if that code is needed it can be resurrected from the github repo so there is no harm in removing it not if it's not used. One less bit of noise.

about 280 Bytes of flash memory saved.

Any savings in flash we can claw back are worth it... means the radios like the X9D+ family get a little more wiggle room for features. It seems from a recent breakage on the 2.8 branch there was a hidden overflow causing those radios to randomly brick when bootloader flashed which we've been able to resolve... and there are some more flash savings coming soon... so the future is still looking good for those radios continuing to learn new tricks and be actively supported. Plus, it means I may be able to turn more of the firmware translations back on, as a couple had to be dropped for those radios.

@HThuren
Copy link
Contributor

HThuren commented Jan 27, 2023

@pfeerick, thank you for this comment and point of view

@mha1
Copy link
Contributor Author

mha1 commented Jan 27, 2023

@pfeerick model_templates.cpp's fate is in your hands. I won't touch it here. I mean it doesn't hurt at all, just noticed it is not referenced as part of any build (not in \src\gui\128x64\CMakeLists.txt).

@mha1
Copy link
Contributor Author

mha1 commented Jan 27, 2023

@pfeerick I have created a separate PR #3119 as a work result of the discussion so far and leave this PR as open draft for further ideas and discussions

@mha1
Copy link
Contributor Author

mha1 commented Jun 1, 2023

I think this served its purpose

@mha1 mha1 closed this Jun 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants