Menu

#3 filename in tsmarty2c.php

1.1.0
closed
None
5
2014-04-08
2012-02-03
Anonymous
No

I like program, but the worst thing about smarty_gettext (for me) it\'s the extraction of text. The better solution should be a smarty2php, but after that done, I\'m working with a very little improvement in tsmarty2c.php, the only thing that I have done is to add the name of the file in comments each time you do a file.

Look at the following code:

function do_file($file)
{
$content = @file_get_contents($file);

if (empty($content)) {
return;
}

global $ldq, $rdq, $cmd;

preg_match_all(\"/{$ldq}\\s*({$cmd})\\s*([^{$rdq}]*){$rdq}([^{$ldq}]*){$ldq}\\/\\\\1{$rdq}/\", $content, $matches);

// IVAN: print file name
print \"// $file\\n\";

for ($i=0; $i < count($matches[0]); $i++) {
if (preg_match(\'/plural\\s*=\\s*[\"\\\']?\\s*(.[^\\\"\\\']*)\\s*[\"\\\']?/\', $matches[2][$i], $match)) {
print \'ngettext(\"\'.fs($matches[3][$i]).\'\",\"\'.fs($match[1]).\'\",x);\'.\"\\n\";
} else {
print \'gettext(\"\'.fs($matches[3][$i]).\'\");\'.\"\\n\";
}
}
}

Now If I have some error, or need to search for a file, I can go to the .C file and search the .tpl file.

Thanks in advance.

Discussion

  • Elan Ruusamäe

    Elan Ruusamäe - 2013-11-22

    https://github.com/glensc/smarty-gettext solves this issue by producing .pot file

     
  • bilbo-the-hobbit

    Hello,

    you may have not noticed by the project just go a new owner :)

    its forge is here https://forge.fusiondirectory.org/projects/smarty3-i18n and i was about to look at all the patches and include them if worthwhile.

    Could i ask you to take an account there and submit all your patches so we can include it.

    We already published a 1.0 with some of the patches we collected

    Cheers

     
  • Elan Ruusamäe

    Elan Ruusamäe - 2014-04-08
    • status: open --> closed
    • assigned_to: Elan Ruusamäe
    • Group: --> Next_Release_(example)
     

Log in to post a comment.

MongoDB Logo MongoDB