LiveTranslator (forked NetteTranslator)

Notice: This thread is very old.
hejdav
Member | 50
+
+1
-

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
+
0
-

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:

  1. Is there a way how to import existing translations from gettexttranslator?
  2. Is possible to cache untranslated strings NOT into session, but elsewhere? (db, file…) so different translators could share same untranslated strings.
  3. 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).
  4. 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:

  1. Forms are translated automatically by Nette, you don't need to use that createComponent() thing
  2. Debugger panel could be also added from config.neon:
nette:
	debugger:
		bar:
			- LiveTranslator\Panel
  1. 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)

Aurielle
Member | 1281
+
0
-

http://puu.sh/6brDB.png When I tried to switch to Czech.

Robyer
Member | 74
+
0
-

@Aurielle You have to start session manually in startup() or set session autostart: true in config.neon

hejdav
Member | 50
+
0
-

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
+
0
-

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:

  1. Not sure with this, I'll try.
  2. Thanks, I will include this.
  3. Right, your variant is cleaner.
Aurielle
Member | 1281
+
0
-

Robyer wrote:

@Aurielle You have to start session manually in startup() or set session autostart: true in config.neon

I was reporting a demo problem here, not my own. Also, the config.neon in your message is wrong, it is autoStart: true (notice the capital S).

Robyer
Member | 74
+
0
-

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
+
0
-

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)

hejdav
Member | 50
+
0
-

TomasA wrote:

I have instaled new version via composer and it didn't work…

It's already fixed, update to newest version.

btw I'm sorry for replying too late.

Last edited by hejdav (2014-05-15 00:10)

kralik
Member | 230
+
0
-

Hi,
please can I somehow set the router to nice url.
Now i have:

<?php
http://127.0.0.1/knihy/www/?lang=cs
?>

I would like have like this:

<?php
http://127.0.0.1/knihy/www/cs/
?>

Thanks a lot
Tomas

Last edited by kralik (2015-10-01 11:25)

Robyer
Member | 74
+
0
-

kralik wrote:

Hi,
please can I somehow set the router to nice url.

Simply use “lang” as any other parameter in your router. For example:

new Route('[/<lang [a-zA-Z]{2}>]/<presenter>/<action>[/<id>]', 'Homepage:default');
kralik
Member | 230
+
0
-

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
+
0
-

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
+
0
-

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

kralik
Member | 230
+
0
-

Hello, please advice.

On the local hosting me LiveTranslator functioned without problems and přpínal between languages CZ / EN.
After moving to hosting after klikutá languages not to switch?

Where could the problem be?

Thank you