LiveTranslator (forked NetteTranslator)
- hejdav
- Member | 50
Hi, I'm introducing interactive text translator (localization tool) for Nette
Framework 2, named LiveTranslator. It's forked from NetteTranslator, whose
official development already died.
For more details try
demo, see LiveTranslator addon page or LiveTranslator Github page
including installation and usage instruction.
This is thread to discuss about this addon.
Last edited by hejdav (2014-02-10 23:15)
- Robyer
- Member | 74
Hi, I'm glad that such translator is alive again. Thanks :)
I use gettexttranslator at this moment and I am thinking about moving to your livetexttranslator and I have few questions:
- Is there a way how to import existing translations from gettexttranslator?
- Is possible to cache untranslated strings NOT into session, but elsewhere? (db, file…) so different translators could share same untranslated strings.
- Could be setting of plural forms separated from setting availablelangs? Plural forms aren't dependent on application, but only on language itself so it would make sense to have one separated config file with languages and their plural forms. (optionally it could be included in component's archive or examples so it could be shared).
- I'd like to manage translations directly in administration (form with orig-translated inputs showed all at once) so I don't need to show debugbar on production. Is there method that could give me array of all strings in original-translated format for particular language and then method to save this whole array of more translated strings at once?
EDIT: Few suggestions to your readme on GitHub:
- Forms are translated automatically by Nette, you don't need to use that createComponent() thing
- Debugger panel could be also added from config.neon:
nette:
debugger:
bar:
- LiveTranslator\Panel
- Alternate way for setting translator for templates (maybe it's better/cleaner, maybe not, idk):
protected function createTemplate($class = NULL) {
$template = parent::createTemplate($class);
$template->setTranslator($this->translator);
return $template;
}
Last edited by Robyer (2014-01-06 10:41)
- hejdav
- Member | 50
Aurielle wrote:
http://puu.sh/6brDB.png When I tried to switch to Czech.
fixed
PS: It's weird – when I created it, it worked.
Last edited by hejdav (2014-01-06 15:40)
- hejdav
- Member | 50
Hi Robyer,
1. gettextTranslator stores translations into .PO and .MO files (each
contains complete data independently).
You can write script to move existing translations from PO file (MO is binary,
PO is plaintext) into new storage, probably db. It wouldn't be too
complicated.
2. I'll think about this later.
3. Maybe you're right, but at now you can define parameters in your config and just bring them in setAvailableLanguages options:
parameters:
pluralForms:
en: "nplurals=2; plural=(n==1) ? 0 : 1;"
...
services:
translator:
setup:
- setAvailableLanguages([
en: %pluralForms.en%
cz: %pluralForms.cz%
])
4. I think this is probably not the way for which LiveTranslator was
designed. Panel is for webs where is no administration (or is not so complex).
If your web have administration, it is indeed better to do translations in it.
But there are actually another tools to do this (maybe Kdyby\Translation
?).
But you do not have to have enabled debugbar on production. We make translations
in debugbar on dev-server (localhost) and translations are deployed onto
production (someway).
Suggestions to readme:
- Not sure with this, I'll try.
- Thanks, I will include this.
- Right, your variant is cleaner.
- Robyer
- Member | 74
hejdav wrote:
3. Maybe you're right, but at now you can define parameters in your config and just bring them in setAvailableLanguages options:
Well, I load list of available languages from database (in BasePresenter), that's why I'd like to set language plural form independently on actually available languages. Just separate “pluralForms” and “availableLangs” in config and it'll be all right.
4. I think this is probably not the way for which LiveTranslator was designed. Panel is for webs where is no administration (or is not so complex).
It's really simple administration, that's why I wanted simple translator, like this one.
But you do not have to have enabled debugbar on production. We make translations in debugbar on dev-server (localhost) and translations are deployed onto production (someway).
Point is that translators of page content aren't web developers. They have no access to sources of webpage nor the needed knowledge to do it. That's why I liked your translator, which allow saving translations in text files or database (or whereever).
I thought I'll use text files, which I'll sent to somebody and he'll return
me same file just with added translations. Just like I could do it with PO
files, but easier.
Or I was thinking about adding simple page to administration where they'll see
list of original strings and next to each string input for translation.
One problem with text files from your translator is that they aren't easily readable. Second problem is lack of list of all (even untranslated) strings (as I mentioned in my 2. question).
I haven't tried your db storage for translations yet, but I think it has same second problem.
- TomasA
- Member | 11
I have instaled new version via composer and it didn't work. I think it's because I am on Debian and I have found this:
In “livetranslator/LiveTranslator/Storage/File.php” at line 180 is this line:
$filePath = "$this->storageDir\\$file";
It started work, when I correct it like that:
$filePath = "$this->storageDir/$file";
Last edited by TomasA (2014-05-04 11:37)
- kralik
- Member | 230
Hi,
I use a live translator is great.
Now I stumbled a bit.
I would like to send mail using a Latte template from Model.
Unfortunately nette my report: ‘Filter 'translate’
not found.
How can I send e-mail directly from the model using the Latte and
translation (LiveTranslator)
In this model, I use of documentation:
<?php
$latte = new Latte\Engine;
$params = array(
'orderId' => 123,
);
$mail = new Message;
$mail->setFrom('Franta <franta@example.com>')
->addTo('petr@example.com')
->setHtmlBody($latte->renderToString('email.latte', $params));
?>
Thanks
- Robyer
- Member | 74
kralik wrote:
I would like to send mail using a Latte template from Model.
Unfortunately nette my report: ‘Filter 'translate’ not found.
https://forum.nette.org/…-application
So register translate filter manually, like here: https://api.nette.org/…ate.php.html#…
- kralik
- Member | 230
Robyer wrote:
kralik wrote:
I would like to send mail using a Latte template from Model.
Unfortunately nette my report: ‘Filter 'translate’ not found.https://forum.nette.org/…-application
So register translate filter manually, like here: https://api.nette.org/…ate.php.html#…
I am LAMA.
I don't know, what I use in $template->setTranslator()
I use in BasePresenter:
<?php
public function injectTranslator(\LiveTranslator\Translator $translator) {
$this->translator = $translator;
}
?>
Thanks