Commit Graph

68 Commits

Author SHA1 Message Date
mattias
4927175872 lazutils: less hints
git-svn-id: trunk@65011 -
2021-04-17 11:28:55 +00:00
juha
3f78f0d62d New optimized functions in LazUtils: FilenameExtIs and FilenameExtIn. Used instead of CompareFileExt and similar.
git-svn-id: trunk@64583 -
2021-02-15 08:43:50 +00:00
juha
751852a44a LazUtils: New function UTF8CompareLatinTextFast. Use in IDE instead of UTF8CompareText.
git-svn-id: trunk@64385 -
2021-01-14 13:52:23 +00:00
juha
42850cfe4d LazUtils: Deprecate now obsolete unit LazUtf8Classes and remove its references from Lazarus code.
git-svn-id: trunk@64384 -
2021-01-14 12:41:32 +00:00
juha
3ea7788cbf Optimize CompareFileExt in different ways. Comparison of FPC/Lazarus generated files can be case-sensitive.
git-svn-id: trunk@64374 -
2021-01-10 19:07:52 +00:00
maxim
85ba39c0d9 LazUtils, Translations unit: improved TPOFile.Modified property handling: initialize its value in constructor and properly set it when removing an item from .po file
git-svn-id: trunk@61361 -
2019-06-11 22:35:16 +00:00
maxim
9843d887dd LazUtils, Translations unit: improve TPOFile constructors (initialize FAllEntries field only once and invalidate statistics regardless of called constructor)
git-svn-id: trunk@61349 -
2019-06-09 22:20:41 +00:00
maxim
436ce8ff84 LazUtils, Translations unit: when updating an item, ensure that translation is empty in .pot file before checking for it. Allows to always correctly clear item's PreviousID value in .pot file.
git-svn-id: trunk@61343 -
2019-06-08 23:00:57 +00:00
maxim
772f1b8843 LazUtils, Translations unit: correctly remove PreviousID parts even in case when empty translation of an item with fuzzy flag set (and non-empty PreviousID) gets populated with translation suggestion
git-svn-id: trunk@61342 -
2019-06-08 22:17:26 +00:00
maxim
eb107de5ed LazUtils, Translations unit: fixed setting PreviousID parts of newly changed items (do not remove just set up PreviousID anymore)
git-svn-id: trunk@61333 -
2019-06-06 23:39:39 +00:00
maxim
81b06ad0e5 LazUtils, Translations unit: calculate translation statistics based on actual file contents, ignoring any corrections made when reading it
git-svn-id: trunk@61303 -
2019-05-30 23:45:14 +00:00
maxim
fc4ab0cea8 LazUtils (Translations unit), POChecker: Introduced VirtualTranslation property to TPOFileItem. It allows to identify items whose empty translations (actually stored in the file) were replaced by some suggestions. Use it in POChecker in order to avoid false warnings about translation contents not yet present in the file.
git-svn-id: trunk@61302 -
2019-05-30 23:21:49 +00:00
maxim
b04174617e LazUtils (Translations unit), POChecker: Store item's fuzzy flag state as read from file in a separate property. Use it where appropriate. This allows to simplify TPOFile constructors and makes code more clear.
git-svn-id: trunk@61299 -
2019-05-28 23:34:39 +00:00
maxim
c38c503588 LazUtils, Translations unit: Removed TPOFile.CleanUp method. Unneeded PreviousID parts of items are now cleaned up when updating items both in .pot templates and .po translations.
git-svn-id: trunk@61293 -
2019-05-26 23:55:57 +00:00
maxim
837b7ebe9c LazUtils, Translations unit: always remove Translation and PreviousID parts of items in .pot templates
git-svn-id: trunk@61290 -
2019-05-24 23:39:24 +00:00
maxim
f7571f5012 LazUtils, Translations unit: When copying found translation value to newly added item, do not copy flags from found item.
This can be confusing for translator (in case if e.g. no-object-pascal-format flag is copied) and desyncs flags in translation from flags in base file (this will cause all flags missing in base file to be removed from translation on next regeneration). Moreover, set of these flags can differ depending on translation in case they are copied from different items which have different flags (e.g. in partially translated files).

git-svn-id: trunk@61284 -
2019-05-23 23:30:27 +00:00
maxim
cc4f34a35e LazUtils, Translations unit: Simplified ModifyFlag method. Now we treat space character as a flag delimiter in all cases, thus improving parsing of flags in case of missing comma characters.
git-svn-id: trunk@61283 -
2019-05-23 22:52:31 +00:00
maxim
a620891184 LazUtils, Translations unit: added comment
git-svn-id: trunk@61281 -
2019-05-22 23:13:33 +00:00
maxim
8078feaa66 LazUtils, Translations unit: When setting flags for an item in .po file, omit double quote (") characters in order to avoid regeneration instability. These characters are not meant to be present in flags anyway according to examples in gettext documentation.
git-svn-id: trunk@61279 -
2019-05-22 22:43:57 +00:00
maxim
592a9daf42 LazUtils, Translations unit: ensure uniqueness of flags in .po file items, ignore empty flags
git-svn-id: trunk@61267 -
2019-05-21 23:50:58 +00:00
maxim
e27c505be2 LazUtils, Translations unit: treat items with no-object-pascal-format flag as having correct formatting (never mark them with fuzzy and badformat flags for the formatting reasons)
git-svn-id: trunk@61232 -
2019-05-16 23:05:04 +00:00
maxim
5b72fe1d56 LazUtils, Translations unit: fixed/improved propagation logic of translation items user flags:
In base .pot file (template):
- Newly created item has no user flags.
- Existing updated item has its user flags kept intact.

In translation .po file:
- Newly created item gets user flags copied from base file (all flags missing in base file are removed).
- Existing updated item gets user flags copied from base file (all flags missing in base file are removed except fuzzy flag, whose state is kept).

After copying user flags, object-pascal-format, badformat and fuzzy flags are set automatically for each item (if needed).

This makes flags in translations (.po files) follow the ones from base file (.pot file) when they are added or removed in all cases (even when an item in .pot file gets its last flag deleted).

git-svn-id: trunk@61231 -
2019-05-16 22:49:46 +00:00
maxim
75a8b1b83c LazUtils: .pot/.po file generation and update improvements by Yuriy Sydorov, bug #35543:
- Automatically set the "object-pascal-format" flag for strings containing format chars. It allows tracking of format errors by external tools such as Poedit.
- The "no-object-pascal-format" flag can be specified for a string in the main .pot file if needed.
- It is possible to specify flags in the main .pot file for particular strings and these flags will be preserved and propagated to language specific .po files during the update.
- Fixed delimiter for flags. At least Poedit expects that flags are separated by comma and space, not just comma.
- TPOFileItem.ModifyFlag() can accept the comma separated list of flags and returns true if the Flags property has been modified.

git-svn-id: trunk@61225 -
2019-05-13 23:19:17 +00:00
maxim
1a22de281f LazUtils, Translations unit: simplify TPOFile.UpdateStrings method, there is no more particular need in early detection of multilined strings. No functional changes.
git-svn-id: trunk@60574 -
2019-03-03 23:17:22 +00:00
maxim
7e998b13d9 LazUtils, Translations unit: when reading resource string files, do not escape TAB character with its code representation ('#9'), it is handled just fine both by our translation system and Poedit
git-svn-id: trunk@60411 -
2019-02-12 18:59:48 +00:00
maxim
c1e3ea24a0 LazUtils, Translations unit: when reading PO file, '\t' sequences are converted to TABs (code #9). Now for symmetry TABs are converted back to '\t' when writing PO files.
git-svn-id: trunk@60369 -
2019-02-08 23:45:45 +00:00
maxim
8d056d676d LCL, LazUtils: do not meddle with trailing lineendings of multiline strings in PO files.
Reasons:
1. PO format does not prohibit multiline strings without trailing lineendings (and e.g. recent versions of Poedit do not complain about them).
2. Now multiline strings in PO files match exactly corresponding resourcestrings.
3. As a consequence of previous point we unbroke loading multiline translations from MO files.

git-svn-id: trunk@60343 -
2019-02-06 00:46:01 +00:00
maxim
040d1106ac IDE/Packager/LazUtils: factored out PO filename parsing code to a separate procedure and made it dotted filename safe. Now using it in all relevant places, thus reducing code duplication and fixing possible problems with dotted PO filenames.
git-svn-id: trunk@60245 -
2019-01-29 23:04:16 +00:00
juha
c9e4614e17 Delete old deprecated methods.
git-svn-id: trunk@59175 -
2018-09-28 11:06:40 +00:00
maxim
db62862efe LCLTranslator, Translations units: when translating an item, return original value if translation is empty. Idea by Sergey Bulba. Also improved finding master .po file in LCLTranslator. Fixes bug #33095.
git-svn-id: trunk@58976 -
2018-09-13 22:03:54 +00:00
ondrej
f34c00fc64 LazUtils: use LazLoggerBase instead of LazLogger
git-svn-id: trunk@58082 -
2018-06-02 16:38:22 +00:00
maxim
ec056fba9f LazUtils: Translations unit: do not try to initialize FHelperList on every call of TPOFile.UpdateItem. FHelperList is only used in TPOFile.SaveToStrings and initialized there.
git-svn-id: trunk@58005 -
2018-05-22 22:32:45 +00:00
maxim
6d88044e80 LazUtils: Translations unit: minor optimization of TPOFile.UpdateItem
git-svn-id: trunk@58004 -
2018-05-22 22:08:06 +00:00
maxim
00b84fd256 LazUtils: Translations unit: simplified TPOFile.FillItem method
git-svn-id: trunk@57997 -
2018-05-21 22:41:03 +00:00
maxim
78acd67a99 LazUtils: Translations unit: introduced TPOFile.InvalidateStatistics method in order to let user to force statistics recalculation if the need arises.
git-svn-id: trunk@57979 -
2018-05-20 22:27:39 +00:00
maxim
99703bc40b LazUtils: Translations unit: removed historical description from comment in the file header (it mentioned no longer existing files/properties). Complete history is available in SVN.
git-svn-id: trunk@57966 -
2018-05-18 23:03:15 +00:00
maxim
0c938e3691 LazUtils: Translations unit: refactored TPOFile statistics (translated/untranslated/fuzzy counters) calculation:
1) Do not try to calculate statistics while reading/updating PO file. Instead calculate it on first read of Statistics property after file read/update. This simplifies logic, makes it easier to maintain and avoids unnecessary calculations when statisics are not actually needed (basically all cases except POChecker).
2) Grouped statistics fields in one record (all these values are usually needed at the same time).
3) Adapted POChecker to the new interface.

git-svn-id: trunk@57965 -
2018-05-18 22:40:50 +00:00
maxim
36b1e31994 LazUtils: Translations unit: do not count errors in TPOFile class anymore, remove NrErrors property.
Reasons:

1) NrErrors was added for POChecker, but it does not use this property.
2) NrErrors count reflected only formatting errors, but this count has little value without list of strings with these errors.
3) PO file errors/problems are not limited by formatting errors (e.g. there can be master/child PO file string mismatches). Detecting them is out of scope of TPOFile class, so NrErrors count in many cases could be misleading.

git-svn-id: trunk@57948 -
2018-05-16 22:26:59 +00:00
maxim
401c1ad2dd LazUtils: Translations unit: declare FindAllTranslatedPoFiles function in interface
git-svn-id: trunk@57828 -
2018-05-07 22:42:16 +00:00
maxim
20834ad1f1 LazUtils, translations.pas: when collecting translation files for given base PO file take into account only files with exactly matching names, i.e. for 'project1.po' collect 'project1.foo.po', not 'project1foo.po'.
git-svn-id: trunk@57545 -
2018-03-21 22:36:01 +00:00
maxim
5f524f7268 LazUtils: translations.pas unit: removed commented out code for context assigning, it will never be used, especially in CleanUp method
git-svn-id: trunk@57501 -
2018-03-12 21:58:06 +00:00
maxim
9306b45921 LazUtils, IDE: remove all unused PO items at once after processing all LRJ/RST/RSJ files, do not rely on PO item identifier structure. This change simpifies item sync logic and guarantees that master PO file will be in sync with LRJ/RST/RSJ files (previously items with not existing unit part of identifier were not removed from master PO file).
git-svn-id: trunk@57491 -
2018-03-09 22:37:25 +00:00
maxim
64656d67ad LazUtils, translations.pas unit: reverted 57426 #a377818801, it caused removal of
strings which should not be removed

git-svn-id: trunk@57431 -
2018-03-02 14:06:19 +00:00
maxim
a377818801 LazUtils: translations.pas unit: removed "module" list (actually list of units extracted from PO items identifiers) handling logic. It significantly complicated the code and these lists were completely unused.
git-svn-id: trunk@57426 -
2018-02-28 23:30:28 +00:00
maxim
2e579f6b18 LazUtils: translations.pas unit: remove deprecated TPOFile.Add method. There is no point in keeping it, because it is unused and it will need to be modified during FModuleList cleanup, so its behavior will change anyway. TPOFile.FillItem method should be used instead.
git-svn-id: trunk@57425 -
2018-02-28 22:46:51 +00:00
maxim
3ebd7fc7fb LazUtils: translations.pas unit: always remove old instance of renamed item from PO file. Before this commit we had the following erratic behavior in some cases (e.g. in files with only one resourcestring):
Change identifier of some resourcestring from "a" to "b" => PO file contains both "a" and "b" items, but should contain only "b" one.

git-svn-id: trunk@57382 -
2018-02-26 23:20:12 +00:00
maxim
32888ff513 LazUtils: translations.pas unit: reduced lowercase function calls
git-svn-id: trunk@57367 -
2018-02-24 23:00:57 +00:00
maxim
62223144ab LazUtils, translations.pas unit: avoid the need to double-regenerate PO files in order to set context correctly when items are changed in the following manner:
"a" -> "c"
"b" -> "c"

Copying fuzzy translations has been disabled because it practically does not help translators and can create potential confusion (some items (like in case above) will appear to have false history, and suggested translation is incorrect anyway). Instead now we guarantee to suggest non-fuzzy translation if it exists.

TPOFile.OriginalList property is removed: it was meant for PoChecker and is not needed by it anymore, its underlying field contents have been changed in order to allow aforementioned changes and most likely will be changed again in near future.

git-svn-id: trunk@57346 -
2018-02-21 23:35:04 +00:00
maxim
73a90daa66 LazUtils: fixed TPOFile.FillItem debugln in translations.pas
git-svn-id: trunk@57327 -
2018-02-18 21:42:38 +00:00
mattias
0b8beb57af lcl: fixed typo
git-svn-id: trunk@57320 -
2018-02-17 10:42:53 +00:00