evilpuncker

Suggestion to localization thing

24 posts in this topic

Translating 147k+ entries is not funny! the current design is like this:

 

this script:

		mes "[Airship Staff]";		mes "When you see a broadcast";		mes "announcing that we have";		mes "arrived at your destination,";		mes "please use one of the exits";		mes "located at the north and";		mes "south ends of the Airship.";		next;		mes "[Airship Staff]";		mes "If you happen to miss";		mes "your stop, don't worry.";		mes "The Airship is constantly";		mes "en route and you'll get";		mes "another chance to arrive";		mes "to your intended destination.";		close;

will generate something like 13 separated strings to translate, my proposal is to make every "npc window" (the text between the start and the close/next) just a single entry, something like this:

   

"[Airship Staff]"; <-- 1 entry only because it repeats
 
"When you see a broadcast
announcing that we have
arrived at your destination,
please use one of the exits
located at the north and
south ends of the Airship."; <-- 2 entry
 
"If you happen to miss
your stop, don't worry.
The Airship is constantly
en route and you'll get
another chance to arrive
to your intended destination."; <-- 3 entry
 
 
 
 
Edited by evilpuncker

Share this post


Link to post
Share on other sites

I personally love this idea (and I did this in the past, in custom scripts I wrote).

 

The only argument that there might be against this is that, by changing the scripts to that format, they might word-wrap differently than official servers. I don't think it's a real issue, but I'd like to hear the others about this.

 

As of commit 09dd209, we actually have source support for a nice syntax such as:

    mes "When you see a broadcast"       // Yep, no semicolon, and no plus sign between this and the next line.        " announcing that we have"       // Just close the quotes and reopen them on the next line.        " arrived at your destination,"        " please use one of the exits"   // Ah, and yes, there can be comments between the lines.        " located at the north and"        " south ends of the Airship.";      // ^ Well, this space is because otherwise there would be no space between "and<>south".
And after the script engine parses it, it's as if there was just one long string in one line (except, it looks prettier in editors, being split in multiple lines.) This also means that the translation engine sees just one string.

Share this post


Link to post
Share on other sites

Translating stuff without a whole context, having only some randomized strings, is not quite intuitive for sure and making translation process harder.
 
But using whole string for all dialogs is not always possible.
I'm not trying to be feature blocker, my point is: there is stylistic text design purpose of leaving message broken on several pieces.
 


Kind of example:

 

mes "Oh...";mes "...Well.";mes "I guess you are right. It is hard.";

↓↓↓

Oh...
...Well.
I guess you are right. It
is hard.

 

 

And

 

mes "Oh... ...Well. I guess you are right. It is hard.";

↓↓↓

Oh... ...Well. I guess
you are right. It is
hard.

 

 

Boths looks worse in-game than a classic way:

 

mes "Oh...";mes "...Well.";mes "I guess you are right.";mes "It is hard.";

↓↓↓

Oh...
...Well.
I guess you are right.
It is hard.

 

 

 

As you can remember, there was some style in official NPC texts.
Making every dialog appear just in single string could break this experience.

Edited by Nebraskka

Share this post


Link to post
Share on other sites

Ah, wonderful point. Yes, I'm aware of those, and I agree. Those /shouldn't/ be merged into one line. A separate 'mes' call would still be kept where necessary -- mostly with line breaks required by the dialogue's punctuation. Translation-wise, those are separate sentences anyways, so it makes less sense for them to be in the same string.

Share this post


Link to post
Share on other sites

T'would be nice if the Script engine would support an automatic line wrap based on x lines. Could even make it a per script config by setting an optional setting in the script start with the tabs?

Share this post


Link to post
Share on other sites

What about:

mes "Oh...";mes "...Well.";mes "I guess you are right. It is hard.";
↓↓↓
"Oh...n...Well.nI guess you are right. It is hard."

Share this post


Link to post
Share on other sites

What about:

mes "Oh...";mes "...Well.";mes "I guess you are right. It is hard.";
↓↓↓
"Oh...n...Well.nI guess you are right. It is hard."
Great, that way we can remove/add lines according to the language(considering some language needs extra words to be put)

@@Haru

Share this post


Link to post
Share on other sites

 

What about:

mes "Oh...";mes "...Well.";mes "I guess you are right. It is hard.";
↓↓↓
"Oh...n...Well.nI guess you are right. It is hard."

 

that is awesome =0 but I suggest that the n to be omitted in pot file so we can translate the full string without the need of editing

(and by the way, since you are a programmer yourself, mind creating a simple tool to convert all npc files to this format you posted? :P)

Edited by evilpuncker

Share this post


Link to post
Share on other sites

(and by the way, since you are a programmer yourself, mind creating a simple tool to convert all npc files to this format you posted? :P)

I guess I could.

 

Edit:

Looking at the current trunk, I do not see support for n in *mes.

Edited by Ai4rei

Share this post


Link to post
Share on other sites

 

What about:

 

mes "Oh...";mes "...Well.";mes "I guess you are right. It is hard.";
↓↓↓

"Oh...n...Well.nI guess you are right. It is hard."
 

that is awesome =0 but I suggest that the n to be omitted in pot file so we can translate the full string without the need of editing

(and by the way, since you are a programmer yourself, mind creating a simple tool to convert all npc files to this format you posted? :P)

Bypassing n in pot :o

How it will detect the newline then....

Share this post


Link to post
Share on other sites

Here you go, see if it works alright (did only basic testing). Requires PHP-CLI:

php collapsemes.php /path/to/npc/folder
Old files are backed up as *.bak, files that need no change are not touched. You might want to use this in a separate working copy in case it screws up.

 

 

collapsemes.php:

#!/usr/bin/php<?php// =================================================================// Collapse consecutive *mes into one, v1.0.1// (c) 2015 Ai4rei/AN//// This work is licensed under a// Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License// ( http://creativecommons.org/licenses/by-nc-sa/3.0/ )// =================================================================// Down-level (PHP 4)if(!function_exists('file_put_contents')){    function file_put_contents($sFileName,$sData)    {        if(($hFile = fopen($sFileName,'wb'))!==false)        {            return fwrite($hFile,$sData) && fclose($hFile);        }        return false;    }}// Down-level Endfunction ProcessFile($sFile){    $bSuccess = false;    echo "File: {$sFile}... load";    if(($sData [email protected]_get_contents($sFile))!==false)    {        echo ' conv';        // mes ( ( var | string ) [,+] )* string; mes "        $sPattern = '/((?<![a-z0-9_])mess+((??:(??:[$.][email protected]?|#{1,2}|')(?:[a-zA-Z0-9_]+)$?)|(??<!)"(?:.(?!(?<!)"))*.?"))s*[,+]s*)*(??<!)"(?:.(?!(?<!)"))*.?))"s*;s*mess+")/sS';        if(preg_match($sPattern,$sData))        {            do            {                $sData = preg_replace($sPattern,'mes $2n',$sData);            }            while(preg_match($sPattern,$sData));            echo ' save';            if(rename($sFile,substr($sFile,0,-3).'bak') && file_put_contents($sFile,$sData))            {                echo " successn";                $bSuccess = true;            }            else            {                echo " failuren";            }        }        else        {            echo " skipn";            $bSuccess = true;        }    }    else    {        echo " failuren";    }    return $bSuccess;}function ProcessPath($sPath){    $bSuccess = true;    echo "Enter: {$sPath}n";    if(($hDir [email protected]($sPath))!==false)    {        while(($sFile = readdir($hDir))!==false)        {            if(substr($sFile,0,1)=='.')            {// unix world: skip self- and parent-references and so-called hidden files                continue;            }            $sFullPath = $sPath.'/'.$sFile;            if(is_dir($sFullPath))            {                if(!ProcessPath($sFullPath))                {                    $bSuccess = false;                    break;                }            }            elseif(is_file($sFullPath) && substr(strtolower($sFile),-4)==='.txt')            {                if(!ProcessFile($sFullPath))                {                    $bSuccess = false;                    break;                }            }        }        closedir($hDir);    }    else    {        echo "Failed to read directory: {$sPath}n";    }    echo "Leave: {$sPath}n";    return $bSuccess;}function Main($nArgc,$aArgv){    if($nArgc<2)    {        echo "Usage: php collapsemes.php <script path>n";        return true;    }    return ProcessPath($aArgv[1]);}if(isset($_SERVER['argc']) && isset($_SERVER['argv'])){    return Main($_SERVER['argc'],$_SERVER['argv']) ? 0 : 1;}die("This script must be run on command line.n");?>
80x15.png

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.

 

 

Edit:

 

v1.0.1: Removed a flag, added regexp overview.

Edited by Ai4rei

Share this post


Link to post
Share on other sites

@@Ai4rei

I'm using uniformserver as webserver, wasn't able to run it properly, created a bat file to execute "php index.php C:UniServerZwwwnpc" (or even changed path to 'npc'), well, tried many things but no success at all lol, I'm too noob for this :P

 

edit: nvm it worked after dropping all files into php folder lol, great work :D

 

now I guess we need to update generator because it is cutting at n (http://i.imgur.com/E5mdDYI.png) but at least now I got only 69k strings to translate

Edited by evilpuncker

Share this post


Link to post
Share on other sites

What about this...

 

1. Convert official scripts to the following format:

mes "[Airship Staff]";mes "When you see a broadcast",    "announcing that we have",    "arrived at your destination,",    "please use one of the exits",    "located at the north and",    "south ends of the Airship.";

 

2. Save multi-line mes commands into the pot file as a single message separated by newlines.

msgid "When you see a broadcastnannouncing that we havenarrived at your destination,nplease use one of the exitsnlocated at the north andnsouth ends of the Airship."

This preserves the official line-breaks while also giving full control to the translator about how to format the message. Importantly, it also keeps the script syntax clean and easy to read (without newline characters all over the place).

Edited by Kpy!

Share this post


Link to post
Share on other sites

2. Save multi-line mes commands into the pot file as a single message separated by newlines.

msgid "When you see a broadcastnannouncing that we havenarrived at your destination,nplease use one of the exitsnlocated at the north andnsouth ends of the Airship."
This preserves the official line-breaks while also giving full control to the translator about how to format the message. Importantly, it also keeps the script syntax clean and easy to read (without newline characters all over the place).

 

 

I like this idea.

Share this post


Link to post
Share on other sites

@@Haru

any news on this? :P I'm currently waiting for any change to be implemented in order to start translating anything, since it is still a pain the current way xD

Share this post


Link to post
Share on other sites

The format of 'mes' messages also needs improvements (ie merge all the lines of a sentence into the same string, be it separated by n or not). I'm personally for not separating it by n (except in the places where a line break is needed), so that the text flow will change accordingly to the font use by a (hexed) client.

 

For mob and NPC names, we currently don't have a plan. I'm open to ideas.

 

Announce/dispbottom, etc are all translatable, by using the _() macro.

 

FluxCP currently doesn't have a maintainer, so I'm not sure whether it'll happen.

Share this post


Link to post
Share on other sites

 

Here you go, see if it works alright (did only basic testing). Requires PHP-CLI:

php collapsemes.php /path/to/npc/folder
Old files are backed up as *.bak, files that need no change are not touched. You might want to use this in a separate working copy in case it screws up.

 

 

collapsemes.php:

#!/usr/bin/php<?php// =================================================================// Collapse consecutive *mes into one, v1.0.1// (c) 2015 Ai4rei/AN//// This work is licensed under a// Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License// ( http://creativecommons.org/licenses/by-nc-sa/3.0/ )// =================================================================// Down-level (PHP 4)if(!function_exists('file_put_contents')){    function file_put_contents($sFileName,$sData)    {        if(($hFile = fopen($sFileName,'wb'))!==false)        {            return fwrite($hFile,$sData) && fclose($hFile);        }        return false;    }}// Down-level Endfunction ProcessFile($sFile){    $bSuccess = false;    echo "File: {$sFile}... load";    if(($sData [email protected]_get_contents($sFile))!==false)    {        echo ' conv';        // mes ( ( var | string ) [,+] )* string; mes "        $sPattern = '/((?<![a-z0-9_])mess+((??:(??:[$.][email protected]?|#{1,2}|')(?:[a-zA-Z0-9_]+)$?)|(??<!)"(?:.(?!(?<!)"))*.?"))s*[,+]s*)*(??<!)"(?:.(?!(?<!)"))*.?))"s*;s*mess+")/sS';        if(preg_match($sPattern,$sData))        {            do            {                $sData = preg_replace($sPattern,'mes $2n',$sData);            }            while(preg_match($sPattern,$sData));            echo ' save';            if(rename($sFile,substr($sFile,0,-3).'bak') && file_put_contents($sFile,$sData))            {                echo " successn";                $bSuccess = true;            }            else            {                echo " failuren";            }        }        else        {            echo " skipn";            $bSuccess = true;        }    }    else    {        echo " failuren";    }    return $bSuccess;}function ProcessPath($sPath){    $bSuccess = true;    echo "Enter: {$sPath}n";    if(($hDir [email protected]($sPath))!==false)    {        while(($sFile = readdir($hDir))!==false)        {            if(substr($sFile,0,1)=='.')            {// unix world: skip self- and parent-references and so-called hidden files                continue;            }            $sFullPath = $sPath.'/'.$sFile;            if(is_dir($sFullPath))            {                if(!ProcessPath($sFullPath))                {                    $bSuccess = false;                    break;                }            }            elseif(is_file($sFullPath) && substr(strtolower($sFile),-4)==='.txt')            {                if(!ProcessFile($sFullPath))                {                    $bSuccess = false;                    break;                }            }        }        closedir($hDir);    }    else    {        echo "Failed to read directory: {$sPath}n";    }    echo "Leave: {$sPath}n";    return $bSuccess;}function Main($nArgc,$aArgv){    if($nArgc<2)    {        echo "Usage: php collapsemes.php <script path>n";        return true;    }    return ProcessPath($aArgv[1]);}if(isset($_SERVER['argc']) && isset($_SERVER['argv'])){    return Main($_SERVER['argc'],$_SERVER['argv']) ? 0 : 1;}die("This script must be run on command line.n");?>
80x15.png

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.

 

 

Edit:

 

v1.0.1: Removed a flag, added regexp overview.

 

hello :P any chance to have it updated in order to work with current system (that has been merged today), well, no hurries tho, but I guess they are not providing a conversion too for all npcs since there are only samples 

Share this post


Link to post
Share on other sites

Just to make sure, to make it support the following?

mes "Lorem ipsum dolor sit amet,\r"

"consectetur adipiscing elit."

↓↓↓
mes "Lorem ipsum dolor sit amet, consectetur adipiscing elit."

Share this post


Link to post
Share on other sites

 

Just to make sure, to make it support the following?

mes "Lorem ipsum dolor sit amet,\r"
    "consectetur adipiscing elit."
↓↓↓
mes "Lorem ipsum dolor sit amet, consectetur adipiscing elit."

 

better wait for @Haru input, by the way since you pointed it out, the early code you provided can work now I guess, can you re-paste it and I'll try to make it work again (I don't really remember how I managed to do so lol)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now