Recent

Author Topic: De-I18n  (Read 2584 times)

zamtmn

  • Hero Member
  • *****
  • Posts: 683
De-I18n
« on: October 04, 2021, 09:05:45 pm »
I translate my prog with po files and TranslateResourceStrings/TranslateUnitResourceStrings, but I need receive original value some resorcestrings. Сan I do this in run time without doubling constants in program sources?

Kays

  • Hero Member
  • *****
  • Posts: 632
  • Whasup!?
    • KaiBurghardt.de
Re: De-I18n
« Reply #1 on: October 04, 2021, 09:40:24 pm »
[…] I need receive original value some resorcestrings. Сan I do this in run time without doubling constants in program sources?
Yesno. Yes, the data is there but the necessary function objPas.getResourceStringDefaultValue was removed in revision 31687. The documentation was updated accordingly just a year ago.

If you just need the default value at one instance, I’d go for the following pattern.
Code: Pascal  [Select][+][-]
  1. const
  2.         boom = 'Boom!'
  3. resourcestring
  4.         bang = boom;
Yours Sincerely
Kai Burghardt

zamtmn

  • Hero Member
  • *****
  • Posts: 683
Re: De-I18n
« Reply #2 on: October 04, 2021, 10:18:07 pm »
@Kays
Thank you for such a detailed answer!

>>I’d go for the following pattern.
This will cause an increase in constants, and the use of different constant names for the original\current values
I will try to use my own translation procedures and build a TDictionary(Current,Original) values


PascalDragon

  • Hero Member
  • *****
  • Posts: 6395
  • Compiler Developer
Re: De-I18n
« Reply #3 on: October 05, 2021, 09:12:27 am »
Yesno. Yes, the data is there but the necessary function objPas.getResourceStringDefaultValue was removed in revision 31687.

The data that ObjPas.GetResourceStringDefaultValue worked on wasn't generated since FPC 2.6.4 anymore (and due to the RESSTRSECTIONS the function wasn't available either). The current data format is similar, but different. If someone provides a patch to introduce missing functionality it will probably be included.

zamtmn

  • Hero Member
  • *****
  • Posts: 683
Re: De-I18n
« Reply #4 on: October 05, 2021, 12:18:11 pm »
PascalDragon
Can I use something map class inside objpas?

PascalDragon

  • Hero Member
  • *****
  • Posts: 6395
  • Compiler Developer
Re: De-I18n
« Reply #5 on: October 05, 2021, 01:28:21 pm »
No, only what is provided by the System unit is available. ObjPas is a low level core unit and any other Object Pascal unit (modes ObjFPC and Delphi) depends on it.

Kays

  • Hero Member
  • *****
  • Posts: 632
  • Whasup!?
    • KaiBurghardt.de
Re: De-I18n
« Reply #6 on: October 05, 2021, 04:08:41 pm »
This will cause an increase in constants, and the use of different constant names for the original\current values
Use scopes if you don’t like that:
Code: Pascal  [Select][+][-]
  1. unit defaultMessages;
  2. interface
  3. const
  4.         foo = 'Foobarable';
  5. implementation
  6. end.
Code: Pascal  [Select][+][-]
  1. unit megawaffle;
  2. interface
  3. uses
  4.         defaultMessages;
  5. resourceString
  6.         foo = foo;
  7. implementation
  8. end.
Thus in megaWaffle the identifier foo refers to the possibly translated message, and the FQI defaultMessages.foo always refers to the untranslated version.

The data that ObjPas.GetResourceStringDefaultValue worked on wasn't generated since FPC 2.6.4 anymore […]
I see. I couldn’t’ve guessed that from the commit message. Thanks for the clarification.
Yours Sincerely
Kai Burghardt

zamtmn

  • Hero Member
  • *****
  • Posts: 683
Re: De-I18n
« Reply #7 on: October 05, 2021, 09:03:38 pm »
Kays
I think it should look like
Code: Pascal  [Select][+][-]
  1. resourceString
  2.   foo = 'test';
  3. ...
  4.   writeln(foo);
  5.   writeln(GetResourceStringDefaultValue(foo));
No additional const, no TableIndex, no StringIndex

PascalDragon
That is, no already written structures with a quick search will not be used here((
Maybe I can change the TResourceIterator signature, and build a dictionary at a higher level, for example in lazutils.Translations?

 

TinyPortal © 2005-2018