Russian URL Title

102 views
Skip to first unread message

Saadettin Yasir AKEL

unread,
Oct 14, 2014, 6:30:05 AM10/14/14
to dot...@googlegroups.com
Hi,

   I have to write russian news site. I do not write news header (URL Title) with Russian characters. How do I set Russian characters?

Thanks and regards

Jason Tesser

unread,
Oct 14, 2014, 7:15:34 AM10/14/14
to dot...@googlegroups.com
As long as your DB is UTF8 and your system you should be able to type in your locale 

--
You received this message because you are subscribed to the Google Groups "Dotcms User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com.
To post to this group, send email to dot...@googlegroups.com.
Visit this group at http://groups.google.com/group/dotcms.
For more options, visit https://groups.google.com/d/optout.

Saadettin Yasir AKEL

unread,
Oct 14, 2014, 7:37:45 AM10/14/14
to dot...@googlegroups.com
Hi,

   The database is already in UTF-8 mode. I can do russian text input. but do not write in russian URLs, the system stops. :(

Thanks and regards

14 Ekim 2014 Salı 14:15:34 UTC+3 tarihinde LORDs_diakonos yazdı:
As long as your DB is UTF8 and your system you should be able to type in your locale 
On Tue, Oct 14, 2014 at 6:30 AM, Saadettin Yasir AKEL <yasi...@gmail.com> wrote:
Hi,

   I have to write russian news site. In the administration panel, russian works. I do not write news header (URL Title) with Russian characters. How do I set Russian characters?

Thanks and regards

Jason Tesser

unread,
Oct 14, 2014, 7:58:27 AM10/14/14
to dot...@googlegroups.com
Not sure what you mean. Does dotcms throw and error?  Are you saying your browser doesn't write in the special characters.  Can you send a video of what you are doing and maybe the log file 

Saadettin Yasir AKEL

unread,
Oct 14, 2014, 8:33:34 AM10/14/14
to dot...@googlegroups.com
Hi,

   I'm uploading a picture related to my work. After typing in the marked area, I can not do any operation.

Thanks

14 Ekim 2014 Salı 14:58:27 UTC+3 tarihinde LORDs_diakonos yazdı:

Falzone, Chris

unread,
Oct 14, 2014, 9:02:41 AM10/14/14
to dot...@googlegroups.com
Do you have a custom field that generates a urlTitle from this field?  Maybe you are not handling the encoding correctly in the custom field and it is breaking the JS that drives the editor.  

Maybe check your JS Console for an error.

Christopher Falzone

Interactive Developer


A Q U E N T

Digital, Creative, and Marketing Talent


aquent.com

cfal...@aquent.com

beec...@gmail.com

unread,
Oct 14, 2014, 9:09:13 AM10/14/14
to dot...@googlegroups.com
specific coding is as follows (ur-title.vtl),  I could not arrange for russian.



#set($cusFieldVarName="title")
<script>

function updateDisplayURLTitle(){
// get the title entered by the user
var plainTitle = dojo.byId("$cusFieldVarName");
if(plainTitle == undefined || plainTitle.value.length ==0){
dojo.byId("displayURLTitle").innerHTML = "";
dojo.byId("urlTitle").value="";
return;
}
// make a friendly url
var urlTitle = plainTitle.value.toLowerCase();
urlTitle= urlTitle.replace(/^\s+|\s+$/g,"");
urlTitle= urlTitle.replace(/ı/g, "i");
urlTitle= urlTitle.replace(/ğ/g, "g");
urlTitle= urlTitle.replace(/ü/g, "u");
urlTitle= urlTitle.replace(/ş/g, "s");
urlTitle= urlTitle.replace(/ö/g, "o");
urlTitle= urlTitle.replace(/ç/g, "c");
urlTitle= urlTitle.replace(/İ/g, "I");
urlTitle= urlTitle.replace(/Ğ/g, "G");
urlTitle= urlTitle.replace(/Ü/g, "U");
urlTitle= urlTitle.replace(/Ş/g, "S");
urlTitle= urlTitle.replace(/Ö/g, "O");
urlTitle= urlTitle.replace(/Ç/g, "C");
urlTitle= urlTitle.replace(/Х/g, "H");
urlTitle= urlTitle.replace(/ /g, "-");
urlTitle = urlTitle.replace(/[^a-zA-Z0-9-]/g , "");
urlTitle = urlTitle.replace(/\s/g, "-");
while(urlTitle.indexOf("--") > -1){
urlTitle = urlTitle.replace("--",'-');
}
while(urlTitle.lastIndexOf("-") == urlTitle.length -1 ){
urlTitle=urlTitle.substring(0,urlTitle.length -1);
}
// set the values of the display place holder and the custom field
// the   is to hold the div open
dojo.byId("displayURLTitle").innerHTML = urlTitle;
dojo.byId("urlTitle").value=urlTitle;
}


// attach this the text1 field onchange
dojo.addOnLoad(function(){
dojo.connect(dojo.byId("$cusFieldVarName"), "onchange", null, "updateDisplayURLTitle");
}
);
// populate the field on load
dojo.addOnLoad(updateDisplayURLTitle);

</script>
<div id="displayURLTitle" style="height:20px"> </div>





14 Ekim 2014 Salı 16:02:41 UTC+3 tarihinde Chris Falzone yazdı:

Falzone, Chris

unread,
Oct 14, 2014, 10:53:58 AM10/14/14
to dot...@googlegroups.com
Any error in the JS Console that might help?

Kivi Shapiro

unread,
Oct 14, 2014, 10:58:11 AM10/14/14
to dot...@googlegroups.com, beec...@gmail.com
I think this line may be the culprit:


urlTitle = urlTitle.replace(/[^a-zA-Z0-9-]/g , "");

It's eating up all your Cyrillic characters, leaving urlTitle as a null string.

Kivi Shapiro
Qualicom Innovations

Falzone, Chris

unread,
Oct 14, 2014, 11:13:20 AM10/14/14
to dot...@googlegroups.com, beec...@gmail.com
So in some of our structures where we use URL Titles and have Japanese Content, we have had to add an alternate title field.  So the Title field gets the Kanji and this is what is displayed on the site, but the alternate title gets the latin character equivalent.  We first check if alternate title has anything in it before using title to build the urlTitle.  

Maybe you will have to do the same for the Cyrillic?  

Saadettin Yasir AKEL

unread,
Oct 14, 2014, 11:49:58 AM10/14/14
to dot...@googlegroups.com, beec...@gmail.com
Hi,

   I am sending a picture of errors in the JavaScript console. I would be happy if you could help.



14 Ekim 2014 Salı 18:13:20 UTC+3 tarihinde Chris Falzone yazdı:

Saadettin Yasir AKEL

unread,
Oct 14, 2014, 11:59:54 AM10/14/14
to dot...@googlegroups.com, beec...@gmail.com
Hi,

urlTitle = urlTitle.replace(/[^a-zA-Z0-9-]/g , "");  I removed and the problem was solved.  Does such a problem?

Thanks

14 Ekim 2014 Salı 18:49:58 UTC+3 tarihinde Saadettin Yasir AKEL yazdı:

Falzone, Chris

unread,
Oct 14, 2014, 12:00:18 PM10/14/14
to dot...@googlegroups.com, beec...@gmail.com
The only way I can see it throwing an error there is if urlTilte is null.  What is the error it is throwing though?  not just the location of the error.

Saadettin Yasir AKEL

unread,
Oct 14, 2014, 12:24:12 PM10/14/14
to dot...@googlegroups.com, beec...@gmail.com
Hi,

   Detail about the error did not appear. (Kivi Shapiro suggested it.) I deleted the code (urlTitle = urlTitle.replace(/[^a-zA-Z0-9-]/g , ""); )  in url-title.vtl. In this way, the error seems to be settled.

Thanks

14 Ekim 2014 Salı 19:00:18 UTC+3 tarihinde Chris Falzone yazdı:

Kivi Shapiro

unread,
Oct 15, 2014, 4:53:48 PM10/15/14
to dot...@googlegroups.com, beec...@gmail.com
On Tuesday, 14 October 2014 12:24:12 UTC-4, Saadettin Yasir AKEL wrote:
   Detail about the error did not appear. (Kivi Shapiro suggested it.) I deleted the code (urlTitle = urlTitle.replace(/[^a-zA-Z0-9-]/g , ""); )  in url-title.vtl. In this way, the error seems to be settled.

There are two problems with just deleting that line.  The first is that you still need to handle certain punctuation characters including "/", "?", and "%"; the second is that any non-ASCII characters are still not fully supported on the World-Wide Web.  So I think the fuller solution would be to replace these lines...


// make a friendly url
var urlTitle = plainTitle.value.toLowerCase();
urlTitle= urlTitle.replace(/^\s+|\s+$/g,"");
urlTitle= urlTitle.replace(/ı/g, "i");
urlTitle= urlTitle.replace(/ğ/g, "g");
urlTitle= urlTitle.replace(/ü/g, "u");
urlTitle= urlTitle.replace(/ş/g, "s");
urlTitle= urlTitle.replace(/ö/g, "o");
urlTitle= urlTitle.replace(/ç/g, "c");
urlTitle= urlTitle.replace(/İ/g, "I");
urlTitle= urlTitle.replace(/Ğ/g, "G");
urlTitle= urlTitle.replace(/Ü/g, "U");
urlTitle= urlTitle.replace(/Ş/g, "S");
urlTitle= urlTitle.replace(/Ö/g, "O");
urlTitle= urlTitle.replace(/Ç/g, "C");
urlTitle= urlTitle.replace(/Х/g, "H");
urlTitle= urlTitle.replace(/ /g, "-");
urlTitle = urlTitle.replace(/[^a-zA-Z0-9-]/g , "");
urlTitle = urlTitle.replace(/\s/g, "-");
while(urlTitle.indexOf("--") > -1){
urlTitle = urlTitle.replace("--",'-');
}
while(urlTitle.lastIndexOf("-") == urlTitle.length -1 ){
urlTitle=urlTitle.substring(0,urlTitle.length -1);
}


...with something like this:

#set($currentAlphabet = "") ## No default alphabet:  just URLencode everything
##set($currentAlphabet = "a-zA-Z") ## English alphabet
##set($currentAlphabet = "[\u0400-\u052F]") ## Cyrillic alphabet and supplement, per http://en.wikipedia.org/wiki/Cyrillic_script_in_Unicode
## For more Unicode code points, see http://kourge.net/projects/regexp-unicode-block

            // make a friendly url
            var urlTitle = plainTitle.value.replace(/\s+/g,"-"); // Replace whitespace with hyphens
            urlTitle = urlTitle.replace(/-{2,}/g,"-"); // Replace sequences of hyphens with a single hyphen
            urlTitle = urlTitle.toLowerCase(); // This line is optional.  It does respect locale which is nice:  the lowercase version of "I", for instance, is different in English and Turkish

            #if($UtilMethods.isSet($currentAlphabet))
                urlTitle = urlTitle.replace(/[^${currentAlphabet}0-9-]/g , ""); // Strip out everything other than letters in the current alphabet, digits, and hyphens
                urlTitle = urlTitle.replace(/^-|-$/g,""); // Eliminate leading and trailing hyphens AFTER stripping
            #else
                urlTitle = urlTitle.replace(/^-|-$/g,""); // Eliminate leading and trailing hyphens BEFORE encoding
                urlTitle = encodeURIComponent(urlTitle); // If no alphabet is specified then encode reserved ASCII characters and all non-ASCII characters
            #end

You might need to play around with the Unicode values to make sure you're including and excluding the right characters.

Kivi Shapiro
Qualicom Innovations
Reply all
Reply to author
Forward
0 new messages