Recent

Author Topic: Show 'Language-Team' value of po file in application  (Read 6669 times)

stem

  • Jr. Member
  • **
  • Posts: 88
Show 'Language-Team' value of po file in application
« on: December 30, 2018, 11:09:16 pm »
Hi,

with Poedit you can add in the properties a 'Language-Team'. How can I easily show the value of the 'Language-Team' for the currently selected translation in my application? Thank you!

stem

stem

  • Jr. Member
  • **
  • Posts: 88
Re: Show 'Language-Team' value of po file in application
« Reply #1 on: May 04, 2019, 09:54:30 pm »
No ideas?  :'(

 ;)

wp

  • Hero Member
  • *****
  • Posts: 11830
Re: Show 'Language-Team' value of po file in application
« Reply #2 on: May 04, 2019, 10:12:54 pm »
In unit "Translations" you can find a class TPoFile which reads the entire file. Property Header contains the name of the last translator and the name of the team. The following code extracts this information from the header:

Code: Pascal  [Select][+][-]
  1. uses
  2.   Translations;
  3.  
  4. procedure ShowTranslationInfo(AFileName: String; out Team, Translator: String);
  5. var
  6.   pofile: TPoFile;
  7.   L: TStringList;
  8.   i: Integer;
  9.   sa: TStringArray;
  10. begin
  11.   L := TStringList.Create;
  12.   try
  13.     pofile := TPoFile.Create(AFileName);
  14.     try
  15.       L.Text := pofile.Header.Translation;
  16.     finally
  17.       pofile.Free;
  18.     end;
  19.     for i := 0 to L.Count - 1 do begin
  20.       sa := L[i].Split(':');
  21.       if (Length(sa) = 2) then
  22.         case sa[0] of
  23.           'Last-Translator' : Translator := Trim(sa[1]);
  24.           'Language-Team'   : Team := Trim(sa[1]);
  25.         end;
  26.     end;
  27.   finally
  28.     L.Free;
  29.   end;
  30. end;

stem

  • Jr. Member
  • **
  • Posts: 88
Re: Show 'Language-Team' value of po file in application
« Reply #3 on: May 04, 2019, 10:58:18 pm »
Thank you!

 

TinyPortal © 2005-2018