Author Topic: Langfile in Plugins  (Read 3819 times)

0 Members and 1 Guest are viewing this topic.

Offline Sunny C.

  • Addicted member
  • ******
  • Posts: 1.806
  • I ♥ 4I
    • View Profile
Langfile in Plugins
« on: September 23, 2008, 11:57:13 AM »
 :flag-en: I Put this Code:
 :flag-de: ich habe diesen Code:
Code: [Select]
<?php // PLUGIN_TITLE: Test

$nozip 1;
define('IN_CP'1);

$root_path = (!eregi("\/plugins\/"$_SERVER['PHP_SELF'])) ? "./../" "./../../";
define('ROOT_PATH'$root_path);
require(
ROOT_PATH.'admin/admin_global.php');
$lang_folder $config['language_dir'];
$template_folder $config['template_dir'];
require(
"../../lang/".$config['language_dir']."/admin.php");
error_reporting(E_ALL);
show_admin_header();

 :flag-en: in my "admin/plugins/test.php"
 :flag-de: in meine "admin/plugins/test.php" gepackt!

 :flag-en: The Plugin Works perfectly, but the Langfile are bad...
 :flag-de: Das Plugin läuft perfekt, aber die Langfiles werden nicht übernommen...

 :flag-en: I Put the Langtag here:
 :flag-de: Ich habe das Langtag hier eingefügt:
The Tag is: $lang_htmlc_tosinglephp
Code: [Select]
echo '
<form method="post" action="">
  <input type="hidden" name="action" value="findusers">
  <table cellpadding="0" cellspacing="0" border="0" width="100%">
    <tr>
      <td class="tableborder"><table cellpadding="3" cellspacing="1" border="0" width="100%">
          <tr class="tableheader">
            <td colspan="2"><a name=""><b><span class="tableheader">HTML-Converter v2</span></b></a></td>
          </tr>
          <tr class="tablerow">
            <td colspan="2"><p align="center" class="rowtitle">
                <textarea name="cvt_area" rows="21" cols="80" style="font:11px courier; width: 100%">',$converted,'</textarea>
                ;</p></td>
          </tr>
          <tr class="tableheader">
            <td><p class="tableheader">Option (1)</p></td>
            <td><p class="tableheader">Option (2)</p></td>
          </tr>
          <tr class="tablerow">
            <td><table width="100%" border="0">
              <tr>
                <td>$lang_htmlc_tosinglephp</td>
                <td>&nbsp;</td>
              </tr>
            </table></td>
            <td><table width="100%" border="0">
              <tr>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
              </tr>
            </table></td>
          </tr>
        </table></td>
    </tr>
  </table>
</form>';

Im put the Code in lang/myLANG/admin.php
Code: [Select]
$lang_htmlc_tosinglephp = 'Testing';
 :flag-en: But i cant see....
... i seee .... $lang_htmlc_tosinglephp

 :flag-de:
Aber ich sehe diese nicht im Resultat
« Last Edit: September 23, 2008, 01:13:24 PM by Phisker B »

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Langfile in Plugins
« Reply #1 on: September 23, 2008, 02:14:09 PM »
1) you don't need manually include your lang file in plugins. admin/admin_global.php does it for you any way.
2) if you need include a php file inside your plugin, use ROOT_PATH as starting point
3) and finally when you are using single quotes you can not use variables inside the string, they will be ignored and treated as plain text.
Either use double quotes:echo "<form> blah $lang_htmlc_tosinglephp </form>";

Or single quotes but use variables outside the string:echo '<form> blah ' $lang_htmlc_tosinglephp ' </form>';

As a good practice I'd suggest always use variables outside the string weather single or double quotes used, this way its easier read the code ;)
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Sunny C.

  • Addicted member
  • ******
  • Posts: 1.806
  • I ♥ 4I
    • View Profile
Re: Langfile in Plugins
« Reply #2 on: September 23, 2008, 02:32:52 PM »
Thank you very much!