Dismal Shadow

  • Madman in a Box
  • Me: Who is Arantor? Cleverbot: It stands for time and relative dimensions in space.
  • Posts: 1,185
Re: English British support
« Reply #15, on October 12th, 2011, 08:26 PM »
I never understood how it works if pirate and yoda are in english? They are automatically translated for you on post or...? 
“I will stand on my ground as an atheist until your god shows up...If my irreligious bothers you much, and if you think everything I do is heresy to your god I don't care. Heresy is for those who believe, I don't. So, it isn't heresy at all!


   Jack in, Wedge,
   EXECUTE!

Nao

  • Dadman with a boy
  • Posts: 16,082
Re: English British support
« Reply #16, on October 12th, 2011, 08:46 PM »
Technical suggestion...

British.language.php or whatever:

$based_on = 'English';
$txt[..] = '...';
$txt[...] = '....';

Load.php:

if (!empty($based_on))
{
  $original_txt = $txt;
  loadLanguage($based_on);
  $txt = array_merge($txt, $original_txt);
}

(And even better -- cache the resulting language...)
Posted: October 12th, 2011, 08:41 PM
Quote from Arantor on October 11th, 2011, 04:01 PM
I can't see it disappearing either, in which case we might as well remove the internal disable option for it.
Sure...
Quote
Quote
add a version number to every single language file
That's not a bad idea. A little bit tricky to get right, but certainly doable.
It's just a bit annoying to maintain once we hit gold... :-/
Or we could have some sort of script that automatically updates the internal version numbers if it finds any difference against the previously stored file (e.g. we just do a md5 of the contents, after removing comments and whitespace.)
Quote
The variable nature before made it practically impossible to get this one right,
I can see it working, with a 'complex_string' function as I said...
For instance, function_exists('something') could be turned into {function_exists:something} and automatically modified by complex_string. Of course, the more choices, the slower it gets... But we can simply check for strpos($string, '{') before continuing. ({, or <we:, or whatever...)

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: English British support
« Reply #17, on October 12th, 2011, 09:19 PM »
Quote from ~DS~ on October 12th, 2011, 08:26 PM
I never understood how it works if pirate and yoda are in english? They are automatically translated for you on post or...?
That's the thing, it's no different to the code as, say, English British vs English, or Portuguese Brazilian vs Portuguese PT. It's the language around the posts, not the posts themselves...
Quote
(And even better -- cache the resulting language...)
Question. Let's say we have arbitrary language x, based on language y, neither of which is English. Do we load English, then y then x?

Caching is a tricky subject for languages. Caching into the cache folder in the usual fashion? If so, I'm not clear how it helps performance.

Also, other than English British, are there any other language packs that are variants of each other? I remember discussing the above mentioned Portuguese pack, given that the two packs are even closer than British is to English... Is it worth the effort to build something to support it rather than just leveraging a comfortable detail of implementation? If no language is really going to use it, I'd say it wasn't worth the effort.
Quote
(e.g. we just do a md5 of the contents, after removing comments and whitespace.)
No, we should store it as a version number in the file rather than rely on contents as unless we store changes in the DB, the language files should be considered volatile.

Elsewhere I mentioned gathering a list of the languages in a manner that encourages loading the files themselves to get the language's own name from it. Putting the version number would be trivial to load at that point.

As far as variables, I'd say it's dependent on the nature, you don't add per document or brute force changes to strings when they apply to individual strings; I wouldn't throw every string through a test for boardurl for example.
When we unite against a common enemy that attacks our ethos, it nurtures group solidarity. Trolls are sensational, yes, but we keep everyone honest. | Game Memorial

Norodo

  • Oh you Baidu, so randumb. (60 sites being indexed at once? Jeez)
  • Posts: 469
Re: English British support
« Reply #18, on October 12th, 2011, 09:56 PM »
Norwegian Bokmaal and Norwegian Nynorsk are similarish*... But I don't think it's worth creating a thing for it, just make them two different language packs...

*Both of which I can supply, probably, if you need any help, yay!

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: English British support
« Reply #19, on October 12th, 2011, 09:58 PM »
How different are they? Is it spelling variations like English vs British? Grammar changes?

Norodo

  • Oh you Baidu, so randumb. (60 sites being indexed at once? Jeez)
  • Posts: 469
Re: English British support
« Reply #20, on October 12th, 2011, 10:09 PM »
There are a few grammar changes, but I'm not sure if they'll affect Wedge, prolly not. Mostly spelling changes.

Nao

  • Dadman with a boy
  • Posts: 16,082
Re: English British support
« Reply #21, on October 12th, 2011, 10:15 PM »
Quote from Arantor on October 12th, 2011, 09:19 PM
Question. Let's say we have arbitrary language x, based on language y, neither of which is English. Do we load English, then y then x?
Recursive load yeah... Not very efficient :P Nested languages would require caching, definitely.
Quote
Caching is a tricky subject for languages. Caching into the cache folder in the usual fashion? If so, I'm not clear how it helps performance.
$txt = unserialize('...') is only 10% faster than the regular version on index.french.php. Although this is about 50% faster:

Code: [Select]
$txt += array(
  'lang_locale' => 'fr_FR',
  'lang_dictionary' => 'fr',
  'lang_spelling' => 'french',
  'lang_rtl' => false,
  'lang_capitalize_dates' => false,
  'number_format' => '1 234,00',
  'time_format' => '%e %B %Y à %H:%M',
  ...

Also, the file is smaller by about 5%.

Oh, and yeah, most of the time, this format could be used directly in Wedge, rather than used after caching the files...
But it's probably not really worth the hassle. On my local install, loading index.french.php, even when going through loadLanguage and its complicated setup (template_include etc), only takes a millisecond... versus half a millisecond for a simple include() on the var_export version.
Quote
Quote
(e.g. we just do a md5 of the contents, after removing comments and whitespace.)
No, we should store it as a version number in the file rather than rely on contents as unless we store changes in the DB, the language files should be considered volatile.
No no, I do mean having the version number in the file -- I just mean we should have a script, on our side, that will go through the language files and increase the version number inside the files if they're found to have been changed against our reference files (i.e. the previous version)...

Heck, we could have a similar script for all files, so we don't have to modify manually all of those @version strings...
Quote
Elsewhere I mentioned gathering a list of the languages in a manner that encourages loading the files themselves to get the language's own name from it. Putting the version number would be trivial to load at that point.
Agreed.

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: English British support
« Reply #22, on October 13th, 2011, 12:39 AM »
Quote
$txt = unserialize('...') is only 10% faster than the regular version on index.french.php. Although this is about 50% faster:
We can only use that once we have built the final array, we cannot use it to combine English with other elements during the build process.

For any given arrays, if the same (non indexed) key occurs in both arrays, the left hand array element will be used, as per http://php.net/manual/en/language.operators.array.php so if we load English into $txt, then use += to attempt to overlay another language, it's going to fail.

Also note that there are some instances where strings are actually reused without necessarily being aware of it.
Quote
No no, I do mean having the version number in the file -- I just mean we should have a script, on our side, that will go through the language files and increase the version number inside the files if they're found to have been changed against our reference files
I'm thinking instead to attach a script to the post_commit hook of SVN, called on any given commit. If the commit updates anything in /languages/, we have an instant log that something needs to be done. It's all automatable. :D

Nao

  • Dadman with a boy
  • Posts: 16,082
Re: English British support
« Reply #23, on October 13th, 2011, 07:32 AM »
- I meant array_merge of course.

- sounds good. Is it what smf used to update tier changelog number? ;)

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: English British support
« Reply #24, on October 13th, 2011, 09:36 AM »
Quote from Nao on October 13th, 2011, 07:32 AM
- I meant array_merge of course.
That certainly works for the building of arrays for caching, but += is suitable (with aforementioned caveat) for loading language strings from cache.
Quote
- sounds good. Is it what smf used to update tier changelog number? ;)
No. The change log was updated by hand with more than one commit because a previous committer had forgotten to update it.