Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Not a member yet? Click here to register.
Forgot Password?

Localisiations and fallback in general

Asked Modified Viewed 3,672 times
M
Moses479
M
  • Newbie, joined since
  • Contributed 2 posts on the community forums.
  • Started 1 thread in the forums
  • Started this discussions
asked
Newbie

1. I have, as human beeing, a problem with reading somthing like undefined index '519a' its nice and short but u have to be a smart ass to get it that it has somthing to do with forum and viewthread.php ... espechaily if a fusion based site is not the only project u r involved with.

solution: well assorted index names like 'forum_viewthread_blablabla' would make clearer where the trouble comes from, if a file is there, u could do a full text search on localefiles for like 'forum_viewthread_' to get the right one thats missing some localisation on the chosen language.

2. on the contrary, why php fusion is still sticking to files localisation wise?

woulnt it be better having a locales table on the database, featuring alphanumeric indexes for like
package eg. 'forum' and part eg. 'viewthread' and the key storing 'blablabla'


having that its easy to make some sort of:
[syntaxhighlighter brush=php,first-line=1,highlight=0,collapse=false,html-script=false]
function populate_the_locale_array_from_database_table_foo_function($package,$part=FALSE,$key=FALSE,$fallback_to_en=TRUE) {

global $locale;

if (!LOCALESET || !package) {
echo '
<br />LOCALE ERROR: locales selection failed, language or package not set for the language \''.$lang.'\' or/and package \''.$package.'\'.';
} else {
$conditions = 'locale_package = "'.$package.'"';
if ($part) $conditions .= ' AND locale_part="'.$part.'"';
if ($key) $conditions .= ' AND locale_key="'.$key.'"';

$result = dbquery('
SELECT *
FROM '.DB_PREFIX.'locales
WHERE '.$conditions
);

if (!dbrows($result)) {
// that can happen by typos or missing database entrys and we all want know that one(s)!
echo '
<br />LOCALE NOTICE: No locales found for '.$conditions.'.';
} else {
while($data = dbarray($result)) {
$name = $data['locale_package'].'_'. $data['locale_part'].'_'.$data['locale_key'];
$locale[$name] = $data['locale_value_'.LOCALESET];
if (!$locale[$name]) {
if (!$fallback_to_en) {
// spam me with freakin notice(s)!
echo '
<br />LOCALE NOTICE: No locale found for '.$name.' in laguage '.LOCALESET.'.';
} else {
// just be quiet and fallback to en without notice!
$locale[$name] = $data['locale_value_English'];
}
}
}
}
}
}
[/syntaxhighlighter]
adressing it instead of including localisation files.

than wee just needs a another backend site thats allowing to create and remove additional colums for additional languages and can put the blank fields on screen to fill them ... would be just perfect for keeping translations updated, finding whats missing by not having all that stupid notices or/and left blank texts over the whole site!


current localesfiles could be easiely inserted on a table by taking the file name like viewthread as part considering its package as forum and putting its current keys like 519 as keys getting for a language $lang the following:

[syntaxhighlighter brush=php,first-line=1,highlight=0,collapse=false,html-script=false]

$lang = 'English';
$package = 'forum';
$part = 'viewtread';
$key = '519';


$current_locale_string = $locale[$key];

dbquery('INSERT INTO '.DB_PREFIX.'locales
SET locale_package='.$package .',
locale_part='.$part.',
locale_key='.$key.',
locale_value_'.$lang.'="'.$current_locale_string.'"'wink;
[/syntaxhighlighter]

replaceing $locale['519'] with $locale['forum_viewtread_519'] on the code and using locales_from_db function just secondary after the file include until evrything is considired as transfered properly.
Edited by Moses479 on 17-02-2011 10:42,
0 replies

4 posts

J
jikaka
J
jikaka 10
www.rusfusion.ru - russian nss
  • Veteran Member, joined since
  • Contributed 946 posts on the community forums.
  • Started 82 threads in the forums
answered
Veteran Member

code, use the appropriate bb-code, and then read it is not convenient
0 replies
M
Moses479
M
  • Newbie, joined since
  • Contributed 2 posts on the community forums.
  • Started 1 thread in the forums
  • Started this discussions
answered
Newbie

hope its now friendlier or iam not getting what u r addressing (english isnt my first language) ...

or isnt the
[syntaxhighlighter brush=php,first-line=1,highlight=0,collapse=false,html-script=false]some code[/syntaxhighlighter]
not the appropriate one? comeon its not that long!
Edited by Moses479 on 17-02-2011 10:35,
0 replies
S
smokeman
S
  • Veteran Member, joined since
  • Contributed 920 posts on the community forums.
  • Started 79 threads in the forums
answered
Veteran Member

Quote

Moses479 wrote:
1. I have, as human beeing, a problem with reading somthing like undefined index '519a' its nice and short but u have to be a smart ass to get it that it has somthing to do with forum and viewthread.php ...

Well, a very easy method to see what locale-files the actual .php-file use is just to notice in the browser what location your on - eg; /forum/viewthread.php
- then just open up that file via FTP - and take a look at the top in the .php-file - here's the name to the locale-file included.

That's very easy IMO at least..

Ohh, and Im btw not a smart ass.
0 replies
M
MarcusG
M
Ex Senior Dev.
  • Member, joined since
  • Contributed 182 posts on the community forums.
  • Started 5 threads in the forums
answered
Member

Any suggestions regarding development of php fusion are appreciated on this site: http://dev.php-fusion.co.uk
0 replies

Category Forum

Locales Forum - 8

Labels

None yet

Statistics

  • Views 0 views
  • Posts 4 posts
  • Votes 0 votes
  • Topic users 4 members

4 participants

S
S
  • Veteran Member, joined since
  • Contributed 920 posts on the community forums.
  • Started 79 threads in the forums
J
J
jikaka 10
www.rusfusion.ru - russian nss
  • Veteran Member, joined since
  • Contributed 946 posts on the community forums.
  • Started 82 threads in the forums
M
M
Ex Senior Dev.
  • Member, joined since
  • Contributed 182 posts on the community forums.
  • Started 5 threads in the forums
M
M
  • Newbie, joined since
  • Contributed 2 posts on the community forums.
  • Started 1 thread in the forums
  • Started this discussions

Notifications

Track thread

You are not receiving notifications from this thread.

Related Questions

Not yet