![]() |
NDEVR
API Documentation
|
Scans source code for translation macros (_t, _td, etc.) and generates .tr translation files for all supported languages. More...
Public Member Functions | |
| void | addOption (INIFactory &translator, const String &s_label, const String &value) |
| Adds a translation entry to the INI factory, checking for duplicates in debug builds. | |
| void | getFiles (Buffer< File > &files, const File &file) |
| Recursively collects source files with matching extensions. | |
| void | makeTranslation () |
| Performs the full translation generation process: scans all source files, generates the master English translation, and updates all other language files. | |
| void | processString (String &s, Scanner &scan, uint04 start_index, const char *end_seq) |
| Extracts a translation string from source code, handling multi-line strings. | |
| void | replaceStringVars (String &s) |
| Replaces escape sequences in a string with their actual characters. | |
| void | setupFile (INIFactory &translator, File file) |
| Scans a single source file for translation macros and adds entries to the translator. | |
Static Public Member Functions | |
| static void | convertBrackets (INIFactory &ini) |
| Converts square bracket sequences to hash-based placeholders for safe INI storage. | |
| static void | convertFromBrackets (INIFactory &ini, const INIFactory &ref) |
| Converts hash-based placeholders back to square bracket sequences using a reference. | |
| static void | getDirs (Buffer< File > &files, const File &file) |
| Recursively collects directories, excluding known non-source directories. | |
Public Attributes | |
| Buffer< StringView > | complex_tr = { "_td(\"" ,"_tdq(\"", "_tid(\"" } |
| Complex translation macro patterns with label-value pairs. | |
| Buffer< StringView > | complex_utf8_tr = { "_td(\"" ,"_tdq(\"","_tqo(\"" } |
| Complex UTF-8 translation macro patterns. | |
| Buffer< String > | extensions = { String(".h"), String(".hpp"), String(".cpp") } |
| File extensions to scan. | |
| Buffer< StringView > | qt_tr = { "QApplication::translate(\"", "QCoreApplication::translate(\"" } |
| Qt translation function patterns. | |
| Buffer< StringView > | simple_tr = { "_t(\"" ,"_tq(\"","_tqa(\"","_tqs(\"", "_to(\"", "_ti(\"" } |
| Simple translation macro patterns. | |
| Buffer< String > | source_roots = { String("$(NDEVR_SOURCE_DIR)"), String("$(NDEVR_SOURCE_DIR)\\..\\Carlson\\") } |
| Root directories to scan for source files. | |
| File | translation_folder = File("$(NDEVR_SOURCE_DIR)\\Resources\\Translations\\") |
| Directory containing translation files. | |
| StringView | utf8 = "utf8(\"" |
| UTF-8 string literal prefix pattern. | |
Scans source code for translation macros (_t, _td, etc.) and generates .tr translation files for all supported languages.
Definition at line 13 of file TranslationTools.h.
|
inline |
Adds a translation entry to the INI factory, checking for duplicates in debug builds.
| [in] | translator | The INI factory storing translations. |
| [in] | s_label | The translation key label. |
| [in] | value | The translation value. |
Definition at line 73 of file TranslationTools.h.
References INIFactory::addManagedOption(), Translator::DefaultReadableLabel(), INIFactory::getOption(), and INIFactory::hasOption().
Referenced by setupFile().
|
inlinestatic |
Converts square bracket sequences to hash-based placeholders for safe INI storage.
| [in] | ini | The INI factory to modify. |
Definition at line 219 of file TranslationTools.h.
References INIFactory::extraOptionsRef(), StringView::hash(), StringView::indexOf(), IsValid(), and StringView::substr().
Referenced by makeTranslation().
|
inlinestatic |
Converts hash-based placeholders back to square bracket sequences using a reference.
| [in] | ini | The INI factory to restore brackets in. |
| [in] | ref | The reference INI factory with original bracket values. |
Definition at line 237 of file TranslationTools.h.
References INIFactory::extraOptions(), INIFactory::extraOptionsRef(), Dictionary< t_key, t_value, t_hash >::get(), StringView::hash(), String::indexOf(), IsValid(), String::replace(), and String::substr().
Referenced by makeTranslation().
Recursively collects directories, excluding known non-source directories.
| [in] | files | The buffer to accumulate directories into. |
| [in] | file | The directory to scan. |
Definition at line 203 of file TranslationTools.h.
References Buffer< t_type, t_memory_manager >::add(), file, and getDirs().
Referenced by getDirs(), and makeTranslation().
Recursively collects source files with matching extensions.
| [in] | files | The buffer to accumulate files into. |
| [in] | file | The file or directory to scan. |
Definition at line 182 of file TranslationTools.h.
References Buffer< t_type, t_memory_manager >::add(), File::e_file_extension, extensions, file, and getFiles().
Referenced by getFiles(), and makeTranslation().
|
inline |
Extracts a translation string from source code, handling multi-line strings.
| [in] | s | The current line (modified in place to contain the extracted string). |
| [in] | scan | The scanner for reading additional lines if needed. |
| [in] | start_index | The starting index within the string. |
| [in] | end_seq | The end sequence to search for (e.g. "\")"). |
Definition at line 40 of file TranslationTools.h.
References String::beginsWith(), Scanner::currentLine(), String::indexOf(), IsInvalid(), IsValid(), Scanner::nextLine(), replaceStringVars(), String::substr(), String::trimWhiteSpace(), and utf8.
Referenced by setupFile().
|
inline |
Replaces escape sequences in a string with their actual characters.
| [in] | s | The string to process in-place. |
Definition at line 26 of file TranslationTools.h.
References String::replace().
Referenced by processString(), and setupFile().
|
inline |
Scans a single source file for translation macros and adds entries to the translator.
| [in] | translator | The INI factory storing translations. |
| [in] | file | The source file to scan. |
Definition at line 92 of file TranslationTools.h.
References addOption(), complex_tr, StringView::Convert(), Scanner::currentLine(), Translator::DefaultReadableLabel(), file, String::indexOf(), IsValid(), Scanner::nextLine(), processString(), qt_tr, replaceStringVars(), simple_tr, StringView::split(), and String::substr().
Referenced by makeTranslation().