aMule Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

We're back! (IN POG FORM)

Pages: 1 2 3 [4] 5

Author Topic: New AmuleWeb Skin Mod ( Litoral Mod )  (Read 65647 times)

lfroen

  • Guest
Re: New AmuleWeb Skin Mod ( Litoral Mod )
« Reply #45 on: April 30, 2008, 10:12:45 AM »

We use gettext for translations, there's no reason to introduce another format. amuleweb is also a bit different from standard PHP and doesn't use its configuration structure.

I suggest implementing a new function to amuleweb PHP which would take care of the translation. This should be integrated with our standard translation procedure, i.e. using gettext.

Example:
Code: [Select]
<?php print _("Enter password"); ?>

I see that nobody is able to answer a simple question "how real, AMP web application is translated". Let me get this straight - suggestion is to add function "_()" to php core, that will do what?

Quote
Finally, the future of aMule (and aMule Gui) is it not aMuleWeb?
Definitely!
Logged

wuischke

  • Developer
  • Hero Member
  • *****
  • Karma: 183
  • Offline Offline
  • Posts: 4292
Re: New AmuleWeb Skin Mod ( Litoral Mod )
« Reply #46 on: April 30, 2008, 05:19:00 PM »

OK, sorry for not saying this clearly.

I'll give you phpbb2 as an example of translations using php (associative arrays). Drupal for example uses gettext, which I favour, too.

Code: [Select]
$lang = array_merge($lang, array(
'ADMIN_CONFIG' => 'Administrator-Konfiguration',
'ADMIN_PASSWORD' => 'Administrator-Passwort',
'ADMIN_PASSWORD_CONFIRM' => 'Bestätigung des Administrator-Passworts',
[...]
  message_die(GENERAL_MESSAGE, $lang['No_posts_topic']);


I would like to propose a system similar to the following:
We collect all the strings which are necessary in a template and use them for the localisation with amuleweb. It is possible to scan the template files directly for strings to translate with xgettext, so this is an automated task.
The actual translation task will be done by our translation team (after automatically merging as many strings as possible, a small duplication is imho not avoidable) just like it is done with the main application. This is important because our translators already know how to use po files.
To actually use translated strings in a template, we need an interface between the gettext functions in C and the amuleweb PHP language. (http://www.gnu.org/software/gettext/manual/gettext.html#Language-Implementors) Important are the functions GonoszTopi mentioned (normal messages and plural messages) and the function to set the currently used locale.

What do you think?

iz0bbz: We will not abandon other ways of controlling aMule remotely, but *I* would like to focus my current work on the web interface.
Logged

lfroen

  • Guest
Re: New AmuleWeb Skin Mod ( Litoral Mod )
« Reply #47 on: April 30, 2008, 09:07:45 PM »

I think that I still don't understand what _("some string") should do. I will read gettext docs, but idea looks quite possible and not difficult to implement.
Logged

wuischke

  • Developer
  • Hero Member
  • *****
  • Karma: 183
  • Offline Offline
  • Posts: 4292
Re: New AmuleWeb Skin Mod ( Litoral Mod )
« Reply #48 on: April 30, 2008, 10:13:42 PM »

_("some string") is an alias for gettext("some string"), it is used because it less work to type.

This function will replace "some string" by the localised flavour if you use a locale different than English.

An example: print _("some string") will print some string on a English system and irgendeine Zeichenkette on a German system.
Logged

GonoszTopi

  • The current man in charge of most things.
  • Administrator
  • Hero Member
  • *****
  • Karma: 169
  • Offline Offline
  • Posts: 2685
Re: New AmuleWeb Skin Mod ( Litoral Mod )
« Reply #49 on: May 01, 2008, 07:56:58 PM »

lfroen:
gettext_noop("some string") is (as its name says) just a do-nothing, it can be probably defined in PHP, so it doesn't really need an implementation.
_("some string") is just an alias for gettext("some string") as wuischke said, see below (also can be done in pure PHP afaik)

gettext("some string") and ngettext("singular string", "plural string", count) should call the named functions from the gettext library with the given parameters, so they are simply an interface between PHP and the system lib.

The interesting part is selecting a message catalog for translation, which is done by the textdomain("domain-name") gettext function. (The language also has to be set by the setlocale() function.)

If you could code the gettext() and ngettext() functions to PHP, I'd add the translation selection logic.

Of course all this requires that the gettext library is installed.
Logged
concordia cum veritate

lfroen

  • Guest
Re: New AmuleWeb Skin Mod ( Litoral Mod )
« Reply #50 on: May 06, 2008, 05:01:46 PM »


If you could code the gettext() and ngettext() functions to PHP, I'd add the translation selection logic.

Of course all this requires that the gettext library is installed.

Why do you need ngettext()? If I got it right, I should add funtion _() which will call gettext() internally.
Logged

wuischke

  • Developer
  • Hero Member
  • *****
  • Karma: 183
  • Offline Offline
  • Posts: 4292
Re: New AmuleWeb Skin Mod ( Litoral Mod )
« Reply #51 on: May 06, 2008, 05:10:20 PM »

ngettext() is for plural forms.

An example:

You call the following code with different values for the integer value 'n':
Code: [Select]
ngettext("%d download", "%d downloads", n);For a value of '1', it will return "1 download" and for values other than 1 "n downloads", e.g. "12 downloads".
Logged

lfroen

  • Guest
Re: New AmuleWeb Skin Mod ( Litoral Mod )
« Reply #52 on: May 06, 2008, 10:44:08 PM »

How exactly _() should know which one to call?
Logged

GonoszTopi

  • The current man in charge of most things.
  • Administrator
  • Hero Member
  • *****
  • Karma: 169
  • Offline Offline
  • Posts: 2685
Re: New AmuleWeb Skin Mod ( Litoral Mod )
« Reply #53 on: May 06, 2008, 10:55:16 PM »

lfroen, as I said above, you should add gettext() and ngettext(). _() is not a standard gettext library function, it is only a conveniance, see in libintl.h:
Code: [Select]
#define _(x) gettext(x)
Skin developers can do the same in their PHP code, they can define _(x) to be an alias for gettext(x).

If you want to do a favour for skin developers, you can of course add _(x) with the same meaning as gettext(x), and you can also define gettext_noop(x) as a do-nothing function that evaluates to its parameter.
Code: [Select]
#define gettext_noop(x) x
Note that ngettext(s, p, c) does not have any alias.
« Last Edit: May 06, 2008, 10:57:21 PM by GonoszTopi »
Logged
concordia cum veritate

lfroen

  • Guest
Re: New AmuleWeb Skin Mod ( Litoral Mod )
« Reply #54 on: May 07, 2008, 10:01:53 AM »

Quote
lfroen, as I said above, you should add gettext() and ngettext(). _() is not a standard gettext library function, it is only a conveniance, see in libintl.h:

To summarize: adding gettext() and ngettext() as-is, and also have _() which will be alias for gettext(). Why do I need gettext_noop() at all?
Logged

Kry

  • Ex-developer
  • Retired admin
  • Hero Member
  • *****
  • Karma: -665
  • Offline Offline
  • Posts: 5795
Re: New AmuleWeb Skin Mod ( Litoral Mod )
« Reply #55 on: May 07, 2008, 02:12:45 PM »

Because it exists on the intl library and it's more convenient to add it for standards compliance and any other bullshit reason you can think of.
Logged

GonoszTopi

  • The current man in charge of most things.
  • Administrator
  • Hero Member
  • *****
  • Karma: 169
  • Offline Offline
  • Posts: 2685
Re: New AmuleWeb Skin Mod ( Litoral Mod )
« Reply #56 on: May 08, 2008, 05:17:17 AM »

The xgettext program, which extracts strings from the source files for the translators, will also recognize gettext_noop(), and extract the string it contains. It is just a marker for a string to be translated. See http://www.gnu.org/software/gettext/manual/gettext.html#Special-cases, I don't know if this is an issue in PHP or not, but if not, we can forget about it.
Logged
concordia cum veritate

lfroen

  • Guest
Re: New AmuleWeb Skin Mod ( Litoral Mod )
« Reply #57 on: May 08, 2008, 09:51:31 AM »

The xgettext program, which extracts strings from the source files for the translators, will also recognize gettext_noop(), and extract the string it contains. It is just a marker for a string to be translated.

That can be a good reason.
Logged

lfroen

  • Guest
Re: New AmuleWeb Skin Mod ( Litoral Mod )
« Reply #58 on: May 12, 2008, 11:48:11 PM »

Support added to php - testing is welcomed.
Logged

wuischke

  • Developer
  • Hero Member
  • *****
  • Karma: 183
  • Offline Offline
  • Posts: 4292
Re: New AmuleWeb Skin Mod ( Litoral Mod )
« Reply #59 on: May 13, 2008, 12:36:07 AM »

linking error: "/usr/bin/ld: cannot find -lintl"

As far as I know, -lintl is unnecessary (included in glibc) and it works if I remove it.

Sorry, how can I set the language in the template? And which message catalogue is used? aMule's?

Edit: It will crash, see backtrace forum for a backtrace.

Anything else I can do to find the source of the error?
« Last Edit: May 13, 2008, 12:52:44 AM by wuischke »
Logged
Pages: 1 2 3 [4] 5