Recent

Author Topic: Idea for a Lazarus addition: resource string validator  (Read 57808 times)

Bart

  • Hero Member
  • *****
  • Posts: 5265
    • Bart en Mariska's Webstek
Re: Idea for a Lazarus addition: resource string validator
« Reply #45 on: January 04, 2012, 06:13:32 pm »
Juha,

I found appr 250 of them, but all of them have a context specified.
I exluded items with a context from the check, based upon the documentation I found in the wiki: http://wiki.lazarus.freepascal.org/Translations_/_i18n_/_localizations_for_programs#Fuzzy_entries.

I can simply add a check for all duplicates if you want, but I think 2 (or more) entries with the same text, but with a context specified, should not be considered an error?

Bart

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4458
  • I like bugs.
Re: Idea for a Lazarus addition: resource string validator
« Reply #46 on: January 04, 2012, 11:12:49 pm »
I found appr 250 of them, but all of them have a context specified.

Where do you see 250 of them?

Quote
I exluded items with a context from the check, based upon the documentation I found in the wiki: http://wiki.lazarus.freepascal.org/Translations_/_i18n_/_localizations_for_programs#Fuzzy_entries.

I can simply add a check for all duplicates if you want, but I think 2 (or more) entries with the same text, but with a context specified, should not be considered an error?

It is not an error, it could be marked as a warning instead.
The context is created automatically by the .po file generator. It means there is never a duplicate without a context.
Some of the duplicates need to be there but most of them could use the same string, IMO. It should be decided case by case.

Juha
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

Bart

  • Hero Member
  • *****
  • Posts: 5265
    • Bart en Mariska's Webstek
Re: Idea for a Lazarus addition: resource string validator
« Reply #47 on: January 05, 2012, 02:12:51 am »
We should have seperate Errors and Warnings (and seperate counters for them then)?

Quote from: Juha
Where do you see 250 of them?

In pofamilies.pp, procedure TPoFamily.CheckDuplicateOriginals, change these lines

Code: [Select]
  for i := FMaster.Count - 1 downto 0 do
  begin
    PoItem := FMaster.PoItems[i];
    Dup := FMaster.OriginalToItem(PoItem.Original);
    if Assigned(Dup) and (Dup.Identifier <> PoItem.Identifier) and (Dup.Context = '') then


into

Code: [Select]
  for i := FMaster.Count - 1 downto 0 do
  begin
    PoItem := FMaster.PoItems[i];
    Dup := FMaster.OriginalToItem(PoItem.Original);
    // remove the check for (Dup.Context = '')
    if Assigned(Dup) and (Dup.Identifier <> PoItem.Identifier)  then

Open lazaruside.po, run only this test and see:

Code: [Select]
--------------------------------------------------
Errors reported by CheckDiplicateOriginals for:
lazaruside.po
--------------------------------------------------

[Line: 17722]
This resourcestring:
#: lazarusidestrconsts.uemsetfreebookmark
msgid "Set a Free Bookmark"
msgctxt "lazarusidestrconsts.uemsetfreebookmark"
has the same value as idenftifier lazarusidestrconsts.lismenusetfreebookmark at line 10971
For this entry it is recommended to set: msgctxt="lazarusidestrconsts.uemsetfreebookmark"

...snip ...

[Line: 12]
This resourcestring:
#: lazarusidestrconsts.dbgbreakgroupdlgcaptionenable
msgid "Select Groups"
msgctxt "lazarusidestrconsts.dbgbreakgroupdlgcaptionenable"
has the same value as idenftifier lazarusidestrconsts.dbgbreakgroupdlgcaptiondisable at line 7
For this entry it is recommended to set: msgctxt="lazarusidestrconsts.dbgbreakgroupdlgcaptionenable"

Found 253 errors.
--------------------------------------------------


Total errors found: 253

Bart

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4458
  • I like bugs.
Re: Idea for a Lazarus addition: resource string validator
« Reply #48 on: January 06, 2012, 01:40:08 am »
We should have seperate Errors and Warnings (and seperate counters for them then)?

[...]

In pofamilies.pp, procedure TPoFamily.CheckDuplicateOriginals, change these lines

I made the change in r34606 and now it reports the duplicates. Good.
I also commented out the message text "For this entry it is recommended..." because it doesn't make sense after the change.

Ideally there should be separate Errors and Warnings. Now I just changed the message text from Error to Error / Warning. No big deal.
In future this test could also be separate from the other checkboxes and the results could be presented in a grid.

Juha
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

Bart

  • Hero Member
  • *****
  • Posts: 5265
    • Bart en Mariska's Webstek
Re: Idea for a Lazarus addition: resource string validator
« Reply #49 on: January 06, 2012, 02:16:57 am »
I'm not happy with the current listing of these duplicate errors (not your modification, but how it turns up in the ErrorLog).

I would like to have it somewhat like this:

The value 'Bar' has duplicates and is used by the follwing ID's
[Line x] lazarusidedstrconst.myres
[Line y] lazarusidedstrconst.anotherres

The value 'Foo' has duplicates and is used by the follwing ID's
[Line z] lazarusidedstrconst.yetanotherres
etc.

I'll re-think that and when I have time re-implement.
Then I'll split it into warnings and errors as well.

Bart

Bart

  • Hero Member
  • *****
  • Posts: 5265
    • Bart en Mariska's Webstek
Re: Idea for a Lazarus addition: resource string validator
« Reply #50 on: January 08, 2012, 05:22:35 pm »
Hi Juha,

I made some changes to the po-checker and uploaded the patch in the bugtracker http://bugs.freepascal.org/view.php?id=21049 and assigned it to you.

  • I changed the way the tool checks for duplicate untranslated values and made the output more readable.
  • RunTests now distinguishes between errors and warnings.
  • Remove some unused vars/consts/resourcestrings.
  • The result dialog now has a functional "Save to file" button.
  • Added glyphs to "save" and "copy" buttons as well.
  • Fixed an error where RunTest tried to acces PoFamilies.FChild when it was unassigned. Now a warning is returned if tests for childs are selected, but no child is available.

Bart

 

TinyPortal © 2005-2018