TP2WScraper
TP2WScraper extracts all strings that are a candidate for getting translated from your project.
How does this thing work?
- Open a (TMS Web Core) project
- Drop a
TP2WScraper
instance on your main form - Run your project in the IDE (F9)
- Click on the button labelled
Extract
- A dialog appears, asking you for a filename
- A file (with every string that is a candidate for getting translated) is getting saved in your
Downloads
directory. - Delete the
TP2WScraper
instance from your main form (optional)
Note: TP2WScraper
will scrape ALL strings in your project, even those that aren't in your main form but in other forms/units.
What is getting scraped?
resourcestring
s- HTML elements with innerText, for example:
- HTML elements with a
data-translate
attribute, for example:
How do I scrape other HTML documents that aren't necessarily associated with a unit?
You can create an event handler for TP2WScraper.OnBeforeScrapeComplete:
function TForm1.P2WScraper1BeforeScrapeComplete(Sender: TObject): TJSPromise;
begin
Result := P2WScraper1.Scrape('Template', 'Template.html');
end;
Where Template
is the scope (probably the name of your HTML document without the extension) and Template.html
is the filename of your HTML document relative to your project's Output directory (probably TMSWeb/Debug
or TMSWeb/Release
).
Great! But what can I do with the generated file?
- The file is compatible with gettext, an internationalization and localization (i18n and l10n) standard for writing multilingual programs.
- The file can get uploaded to crowdin.com where translators can translate it for you, or you can open the file with a PO editor, for example Poedit.
- You can read a translated file back into TP2WTranslator and have it translate your project at runtime (yes, you can change the language at runtime)