Replace post time text from English to other
5 posters
Page 1 of 1
Replace post time text from English to other
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:
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
If this topic already exists do link me to it!
Thank you in advance!
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
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
Re: Replace post time text from English to other
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
Find :
Replace by :
( or add class "lastpostText" )
Save and publish.
Then go to Modules > JavaScript code management > Create a new script
Title : Your choice
Placement : In the homepage
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.
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
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.
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) };
});
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.
Re: Replace post time text from English to other
@Ange Tuteur
can i jump in
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
can i jump in
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
- Posts : 659
Reputation : 29
Language : Arabic and some English
Location : Egypt
Re: Replace post time text from English to other
Michael_vx wrote:@Ange Tuteur
can i jump in
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
Re: Replace post time text from English to other
@_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
am i right ?
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
am i right ?
Michael_vx- Forumember
- Posts : 659
Reputation : 29
Language : Arabic and some English
Location : Egypt
Re: Replace post time text from English to other
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
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.
Then go to Modules > JavaScript code management > Create a new script
Title : Your choice
Placement : In the homepageThe above is an example of text replacement on multiple elements, you can also use the jQuery each() method if you like.
- 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) };
});
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
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?
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
Re: Replace post time text from English to other
You're welcome.
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.
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.
Similar topics
» Replace text to emoticon using javascript
» Text Replace
» Text replace with another one
» Navbar text replace
» Replace text to emoticon (on Forumotion)
» Text Replace
» Text replace with another one
» Navbar text replace
» Replace text to emoticon (on Forumotion)
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum