I'm trying to follow the README file of this translator package, but I'm not sure I'm following… Please be aware that I have VERY LITTLE knowledge of PHP.
I have a project set up something like this:
lang/
--en/language.php
--es/language.php
templates/
--blocks/
----header.php
----[…]
--sections/
----home.php
----[…]
boot.php
index.php // This is where I include my templates and boot.php
My boot.php
goes something like this:
<?php
include_once(__DIR__ . '/vendor/autoload.php');
$lang = (!empty($_GET['lang'])) ? $_GET['lang'] : 'es';
use diversen\lang;
use diversen\translate\extractor;
$l = new lang();
$l->setDirsInsideDir(__DIR__ . '/lang/');
$l->setDirsInsideDir(__DIR__ . '/templates/');
$l->loadLanguage($lang);
$e = new extractor();
$e->defaultLanguage = $lang;
$e->updateLang();
// This is just a shortcut function
function __($str) {
return lang::translate($str);
}
By including boot.php
in my "main template", index.php
, I'd like to add all non-translated strings to their corresponding translation file, but they remain unchanged (ie. nothing is being appended to the translation files)
In my template files I'm using the shortcut function __()
like so:
<?= __('Some string to translate'); ?>
And I'm seeing them rendered as NT: Some string to translate
. I assume NT
stands for Not Translated
or something along those lines.
My apache error logs are not showing anything…