https://github.com/delphiworlds/babel
Lightweight, cross-platform library which helps translate text into the target languages.
https://github.com/delphiworlds/babel
Last synced: 4 months ago
JSON representation
Lightweight, cross-platform library which helps translate text into the target languages.
- Host: GitHub
- URL: https://github.com/delphiworlds/babel
- Owner: DelphiWorlds
- License: mit
- Created: 2023-11-02T02:50:17.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-11-02T05:49:16.000Z (over 2 years ago)
- Last Synced: 2025-05-29T13:53:44.861Z (about 1 year ago)
- Language: Pascal
- Size: 44.9 KB
- Stars: 4
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: ReadMe.md
- License: LICENSE
Awesome Lists containing this project
README
# Babel
A lightweight, cross-platform library which helps translate text into the target languages.
Babel is used for translations in the [Codex](https://github.com/DelphiWorlds/Codex) add-in for Delphi, and for [Mosco](https://github.com/DelphiWorlds/Mosco).
## Features
* Lightweight - Babel is just 3 units: `Babel.Types`, `Babel.Persistence` and `Babel.Locale`
* Compact definition files
## How To Use Babel
### Create definition files
Use Babelizor to scan your project files for `.pas` and `.dfm` and/or `.fmx` files to create a definition file, and add supported languages. Babel will scan for Caption, Text, Hint and Title properties in form definition files and for `resourcestring` values in `.pas` files.
If you have an account for the Google Translate API, use the instant translation tool to create translations for your text.
If using instant translation, Babelizor expects a file called `options.json` in a folder called `Babelizor` under `Public Documents` with content like this:
```json
{
"TranslateAPIKey" : "AIzaSyAzXXXXXXXXXX7u7pcQ"
}
```
where you would replace `AIzaSyAzXXXXXXXXXX7u7pcQ` with your API key.
This is a brief tutorial on how to [create a project, enable the API and get a key](https://www.youtube.com/watch?v=1wcE-DfqNtU&t=37s).
### Using the definition file in your app
Either deploy the definiton file with your app and use the `LoadFromFile` method, or include your definition file as a resource, and use `LoadFromResource`.
To translate the text in forms and datamodules, use the `Translate` method when the form or datamodule is created.
To translate other text values that are in the definition file, use the `Tx` method.
## Demos
### Basic Demo
Demonstrates translation through the use of a resource file (babel.json) created with Babelizor.
## Version History
v1.0.0 (Nov 2nd, 2023)
* Initial release