The forum of the forums
Welcome to the Official Support Forum of Forumotion!

To take full advantage of everything offered by our forum, please log in if you are already a member, or join our community if you've not yet.



Create a free forum like this one.

Replace post time text from English to other

View previous topic View next topic Go down

Solved Replace post time text from English to other

Post by Kami-sama on January 5th 2015, 7:03 pm

Hello!

So, in my forum (version phpBB2) the language of the forum is not English, but some text is yet shown in English. While changing it in "online" table, I used javascript and replace command. For example:
Code:
<script type="text/javascript">
document.getElementById('buve').innerHTML=document.getElementById('buve').innerHTML.replace('Members connected during last 24 hours','Paskutinę parą čia matytos sielos');
</script>

But, yet that does not work when I try to change English words next to latest post time (Today, Yesterday). Well, tbh, it does work, but only for the first row (first forum latest post time). If I place the ID in other places, where logically it should work - it does not. I assume there should be some commands like replaceall or smth?

If you have any questions do ask!
If there is an option, to pitch translations for forumotion, do tell me where!
If you have any solutions for that I hope you will share them Wink

If this topic already exists do link me to it!
Thank you in advance!


Last edited by Kami-sama on January 6th 2015, 2:54 pm; edited 1 time in total

Kami-sama
Forumember

Female Posts : 74
Reputation : 3
Language : English, Russian, German, Lithuanian

http://hogas.huhohi.com/

Back to top Go down

Solved Re: Replace post time text from English to other

Post by Ange Tuteur on January 6th 2015, 12:52 am

Hi @Kami-sama,

The problem is that an ID is meant to be unique to 1 element. For a collection of elements, use a classname instead. Here's an example using a for loop to replace the text on elements with the classname "lastpostText" :

Display > Templates > General > index_box Edit

Find :
Code:
<span class="gensmall">{catrow.forumrow.LAST_POST}</span>

Replace by :
( or add class "lastpostText" )
Code:
<span class="gensmall lastpostText">{catrow.forumrow.LAST_POST}</span>

Save and publish. Add


Then go to Modules > JavaScript code management > Create a new script

Title : Your choice
Placement : In the homepage
Code:
$(function() {
 for (var i=0, s=document.getElementsByTagName('SPAN'); i<s.length; i++) {
  if (/lastpostText/.test(s[i].className)) {
  translate(/Today/, 'todaytext');
  translate(/Yesterday/, 'yestertext');
  }
 }
 function translate(oldText,newText) { if (oldText.test(s[i].innerHTML)) s[i].innerHTML = s[i].innerHTML.replace(oldText,newText) };
});
The above is an example of text replacement on multiple elements, you can also use the jQuery each() method if you like. Wink


For the board language, some are partial translations. As far as volunteer translations go, I'd try and contact Buttercup about that, as she works directly with the company.

Ange Tuteur
Forumaster

Male Posts : 13021
Reputation : 2683
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: Replace post time text from English to other

Post by Michael_vx on January 6th 2015, 7:29 am

@Ange Tuteur
can i jump in Very Happy
i like to ask
if this way can be used to change the way of the date style
like some how on forums who Edit templates the date appear like this
M/D/Y and it should be D/M/Y this one in topics at most also hid or make the date shorter in sub forums because i still did not understand the example yet
and I apologize for jumping in here

Michael_vx
Forumember

Male Posts : 655
Reputation : 29
Language : Arabic and some English
Location : Egypt

Back to top Go down

Solved Re: Replace post time text from English to other

Post by _Twisted_Mods_ on January 6th 2015, 7:41 am

@Michael_vx wrote:@Ange Tuteur
can i jump in Very Happy
i like to ask
if this way can be used to change the way of the date style
like some how on forums who Edit templates the date appear like this
M/D/Y and it should be D/M/Y this one in topics at most also hid or make the date shorter in sub forums because i still did not understand the example yet
and I apologize for jumping in here

you can change date style in your profile options

_Twisted_Mods_
Helper
Helper

Male Posts : 2020
Reputation : 299
Language : English
Location : Ms

http://liquidcode.forumotion.com

Back to top Go down

Solved Re: Replace post time text from English to other

Post by Michael_vx on January 6th 2015, 7:57 am

@_Twisted_Mods_
the problem im talking about only with themes made by template of the date show as M/D/Y instead of D/M/Y
and i dont think the shorting date is from profile settings Very Happy
am i right ?

Michael_vx
Forumember

Male Posts : 655
Reputation : 29
Language : Arabic and some English
Location : Egypt

Back to top Go down

Solved Re: Replace post time text from English to other

Post by Kami-sama on January 6th 2015, 2:26 pm

@Ange Tuteur wrote:Hi @Kami-sama,

The problem is that an ID is meant to be unique to 1 element. For a collection of elements, use a classname instead. Here's an example using a for loop to replace the text on elements with the classname "lastpostText" :

Display > Templates > General > index_box Edit

Find :
Code:
<span class="gensmall">{catrow.forumrow.LAST_POST}</span>

Replace by :
( or add class "lastpostText" )
Code:
<span class="gensmall lastpostText">{catrow.forumrow.LAST_POST}</span>

Save and publish. Add


Then go to Modules > JavaScript code management > Create a new script

Title : Your choice
Placement : In the homepage
Code:
$(function() {
 for (var i=0, s=document.getElementsByTagName('SPAN'); i<s.length; i++) {
  if (/lastpostText/.test(s[i].className)) {
  translate(/Today/, 'todaytext');
  translate(/Yesterday/, 'yestertext');
  }
 }
 function translate(oldText,newText) { if (oldText.test(s[i].innerHTML)) s[i].innerHTML = s[i].innerHTML.replace(oldText,newText) };
});
The above is an example of text replacement on multiple elements, you can also use the jQuery each() method if you like. Wink


For the board language, some are partial translations. As far as volunteer translations go, I'd try and contact Buttercup about that, as she works directly with the company.

Hey! Thank you for your suggestions I will try them out Wink

About the ID. I know it should be one of the kind, but lets say, you put ID in front of everything, so that replacement would happen when all the table is assembled. Then it should replace all? I think when I was working on online table, I tried to replace a space and then all the spaces in the div with that ID were replaced. Am I hallucinating or that might have happened? Very Happy


EDIT: so I've tried it and it works like a charm! Thank you a lot!
One question from that though, why do you need to tick "Home page", why does ticking "all pages" don't work? You would imagine that "all page" means all pages ;D

Kami-sama
Forumember

Female Posts : 74
Reputation : 3
Language : English, Russian, German, Lithuanian

http://hogas.huhohi.com/

Back to top Go down

Solved Re: Replace post time text from English to other

Post by Ange Tuteur on January 7th 2015, 1:34 am

You're welcome. Smile

Technically if you apply an ID to the parent, and then replace the HTML content it should work. Using #main-content would be a good example.

Since the classname lastpostText was applied to only the index_box template ( the homepage ), we wouldn't want to run the same script where it doesn't exist. It wont cause any errors, but it'll iterate over all SPAN elements each time.

Ange Tuteur
Forumaster

Male Posts : 13021
Reputation : 2683
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: Replace post time text from English to other

Post by Base on January 7th 2015, 12:18 pm

Marked as Solved => Archived

Base
Forumaster

Male Posts : 10386
Reputation : 1687
Language : English and French
Location : United Kingdom, England

http://forumotionhub.net

Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum