Solution to translate harcoded tokens in skins (Feature request)

redesb

Verified User
Joined
May 10, 2004
Messages
207
Location
Spain
Hello John,

I think that I have found the definitive solution to the problem to translate 'hardcoded' tokens of skins without making in depth changes in DA.

According to I understand, since to change the binarys of DA it is not a easy option, the solution would have to implement itself modifying only templates and the configuration files

Example of possible solution:

The example is based on the file '... /admin/show_admins.html' but he is extrapolateable to all the archives (and TOKENS) that need it.

Present file ' show_admins.html':
Code:
|?TREE=» <a class=tree
href="/CMD_ADMIN_SHOW">`LANG_SHOW_ADMINS`</a>|
|?HELP_SECTION=`ADMIN_HELPER`/createa.html|
|HTM_ADMIN_TOP|
<a href="HTM_ACCOUNT_ADMIN_CREATE">|LANG_CREATE_ADMIN|</a><br>
<a href="HTM_ACCOUNT_ADMIN_DELETE">|LANG_DELETE_ADMIN|</a><br>

|TABLE|

|HTM_ADMIN_BOTTOM|
Suggested change:
Code:
|?TREE=» <a class=tree
href="/CMD_ADMIN_SHOW">`LANG_SHOW_ADMINS`</a>|
|?HELP_SECTION=`ADMIN_HELPER`/createa.html|
|HTM_ADMIN_TOP|
<a href="HTM_ACCOUNT_ADMIN_CREATE">|LANG_CREATE_ADMIN|</a><br>
<a href="HTM_ACCOUNT_ADMIN_DELETE">|LANG_DELETE_ADMIN|</a><br>

[COLOR=darkred]|HCT_SHOW_ADMINS_TABLE|[/COLOR]

|HTM_ADMIN_BOTTOM|
HCT _ = Acronym of HardCoded Token

It would be necessary to add following to the file ' files_admin.conf ':
Code:
HCT_SHOW_ADMINS_TABLE=admin/show_admins_table.html
And to create the file 'lang/en/admin/show_admins_table.html' with the
following content:
Code:
|TABLE|
The 'HCT_ANY_THING_TOKEN' it is what there would be to add to DA and it would always aim at the directory of the language selected by the user.

This way, to translate harcoded tokens, will be enough with using the macros|*if|*else|*endif|, for example, the version in other language of the previous file would be:
Code:
|$/usr/local/bin/php
<?php
$data = <<<END
|TABLE|
END;
$data = str_replace("english text", "other_language_text", $data);
echo $data;
?>
DONE|
Using this system, it would be easy to totally translate DA to any language without never modify the original templates and only modifying the archives of the 'lang' dirs when updating the version.

John, you think that the idea is attainable?

Ramon
 
Last edited:
Its better to use next code:

$data = preg_replace('/\benglish text\b/', 'other_language_text', $data);

Because of :
if We want to replace word "or" for example and there is a word "Sort" in the Token, The function str_replace replace both "or"!
 
redesb

Using this solution I found that it does not work with token |DIRECTORIES| (section “Password Protected Directories”) and token |DIRECTORYLIST| (section “File Manager”)!

How do you think why is it? And what should I do to translate this token?
 
Welcome to the users club of the not imperial language suffers, Dmitry.

You are right, you can translate these sections due a chroot environment for security, the only solution I encounter to this problem was javascript translation but not finished yet.

Ramon
 
That works? but with the updates that changes will be removed .

I think is better include the hardcoded words os phrases in the lang files

Plz reply to the open threads about that in the "Feedback & Feature Requests"
 
Back
Top