Jump to content

Comments module translation


doolak
 Share

Recommended Posts

As the administration backend of the Comments module is not translated and i have a costumer which does not speak English i am trying to make it translatable.

I already made some parts translatable (Dropdown with "Pending", "Approved", "Spam" and "Delete" and the status which is shown at the right side ("Approved" and "Pending") - now i am trying to translate this part:

"\n\t\t\t<span class='CommentsAdminItemBy'>Comment #$num Posted " . date('m/d/y H:i', $comment->created) . " by " . htmlentities($comment->cite, ENT_QUOTES, 'UTF-8') . "</span>" . 

As this is my first attempt to make a module translatable i made it like this, which works fine for my personal use:

"\n\t\t\t<span class='CommentsAdminItemBy'>".$this->_("Comment")." #$num "
.$this->_("Posted") ." ". date('m/d/y H:i', $comment->created) ." "
.$this->_("by"). " ". htmlentities($comment->cite, ENT_QUOTES, 'UTF-8') . "</span>" . 

But of course it's not very smart to have the words "Comment", "Posted" and "by" translatable as seperate strings and as i saw in the documentation there seems to be a possibility using something like:

$out = sprintf(__("Created %d pages."), $count); 

I tried to make the string translatable in a similar way but i cannot get it to work - would be great if somebody could help me with the part above to show me the right direction.

Link to comment
Share on other sites

$out = sprintf(__("Created %d pages."), $count); 

That code was just an example from the Code Internationalization (i18n) docu (http://processwire.com/api/multi-language-support/code-i18n/) and as far as i understood it right, sprintf or printf are used instead  of the $this->  - i just cannot get the part to work where you use a variable within the translatable string.

Link to comment
Share on other sites

Doolak, I will go ahead and make this translatable and included in the core this week -- didn't realize I'd missed this one. 

Great, thanks - that will make it unnecessary that i have to replace the InputfieldCommentsAdmin.module everytime after an update - or use a duplicate of that module just for the translated part ;-)

But certainly it was a good thing for me to learn a bit about the translatable strings - and thanks to Martijn and Soma, i managed it to include the #$num - part now with the sprintf function:

"\n\t\t\t<span class='CommentsAdminItemBy'>".sprintf($this->_("Comment #%d Posted"),$num)." ". date('d.m.Y H:i', $comment->created) ." "
.$this->_("by"). " ". htmlentities($comment->cite, ENT_QUOTES, 'UTF-8') . "</span>" . 

@ryan: If you will be working on the InputfieldCommentsAdmin.module making it translatable, i have a fews suggestions for the module:

1. Don't know if this makes sense, but would be nice to have a possibility to change the date format in the field settings

2. If you sort newes to oldest - the comment numbers stay counting from 1 to ... - they should be inverted, too.

3. Would be great if instead of "Spam is automatically deleted after the amount of time specified in the field configuration." one could display the amount of time or the date the Spam will be deleted

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...