We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Extension: URL Title Chars

Development and Programming

Laisvunas's avatar
Laisvunas
879 posts
16 years ago
Laisvunas's avatar Laisvunas

The attached add-on files may be out of date. Please visit Devot-ee for the latest versions.

This extension allows you to convert automatically non-latin characters in entry’s URL title according to some predefined set of conversion rules.

There is already extension which does exactly that - CM Strange URL Interpreter. I was not content with it because using it when there is a need to define conversion rule you must make edits both in the language file and in extension file.

Using URL Title Chars extension conversion rule can be defined by editing just language file. To do it you should type a line such as this:

'url_title_char_916'       =>    "d",    // Δ Greek Capital Letter Delta

In this line using symbol’s decimal notation (916) was set that Greek capital letter delta if found in URL title should be converted into latin letter “d”.

Installation:

1) download and unzip the package 2) open the file lang.url_title_chars.php in text editor. 3) edit conversion rules; in order to find each symbol’s decimal representation use Mr. Richard Ishida’s Unicode Code Converter v7 beta 4) upload files to language and extensions folders. 5) enable extension.

       
Kim Ryu Hyun's avatar
Kim Ryu Hyun
65 posts
16 years ago
Kim Ryu Hyun's avatar Kim Ryu Hyun

Great extension! This could be very useful.

I am trying to adapt this extension to support Korean by adding new conversion rules as follows:

‘url_title_char_45392’ => “Nyeon”, // Korean Letter 념 ‘url_title_char_45397’ => “Nyeong”, // Korean Letter 녕 ‘url_title_char_45432’ => “Noh”, // Korean Letter 노 ‘url_title_char_45453’ => “Nong”, // Korean Letter 농 ‘url_title_char_45516’ => “Noe”, // Korean Letter 뇌 ‘url_title_char_45544’ => “Neung”, // Korean Letter 뇨 ‘url_title_char_45768’ => “Ni”, // Korean Letter 니

Each single Korean character represents one syllable, therefore multiple Latin characters as above. Am I doing something wrong here?

Since there are few thousand Korean characters in use today, I am only adding about 400 most used only which should give me not entirely correct but reasonably correct URL titles.

This doesn’t seem to work.

       
Laisvunas's avatar
Laisvunas
879 posts
16 years ago
Laisvunas's avatar Laisvunas

Hi,

The bad effect is that the first capital letter gets truncated isn’t it? To avoid this fron happening open the file /system/cp/cp.publish.php, go to approximately the line 890 and comment out the line

NewText = NewText.replace(/[^a-z0-9-_]/g,'');

Now conversion should proceed correctly.

       
Kim Ryu Hyun's avatar
Kim Ryu Hyun
65 posts
16 years ago
Kim Ryu Hyun's avatar Kim Ryu Hyun

Thanks for responding.

However, I have tried above but nothing has changed.

       
Laisvunas's avatar
Laisvunas
879 posts
16 years ago
Laisvunas's avatar Laisvunas

Hi,

What’s the bad effect? Is it that the first capital letters get truncated?

       
Kim Ryu Hyun's avatar
Kim Ryu Hyun
65 posts
16 years ago
Kim Ryu Hyun's avatar Kim Ryu Hyun

Well, the bad effect is that I get following error message when entering Korean title and leave URL title empty and try to save:

Error
Unable to create valid URL Title for your entry

       
Laisvunas's avatar
Laisvunas
879 posts
16 years ago
Laisvunas's avatar Laisvunas
I get following error message when entering Korean title and leave URL title empty and try to save

You are not supposed to leave URL title empty. When you enter Korean title URL Title Chars extension converts Korean characters into Latin ones and puts them into URL title field; contents of this field should be submitted.

       
Kim Ryu Hyun's avatar
Kim Ryu Hyun
65 posts
16 years ago
Kim Ryu Hyun's avatar Kim Ryu Hyun

Well, when I enter English title in the title field it does convert that into url title field but when I do the same with Korean title, nothing happens.

In addition, empty url title with English title saves just fine. Only the non-Latin doesn’t save with error at the end.

       
Laisvunas's avatar
Laisvunas
879 posts
16 years ago
Laisvunas's avatar Laisvunas
when I enter English title in the title field it does convert that into url title field but when I do the same with Korean title, nothing happens.

If you have URL Title Chars extension installed and have in its language file the lines

'url_title_char_45392'    =>  "Nyeon",      // Korean Letter 념
'url_title_char_45397'    =>  "Nyeong",      // Korean Letter 녕
'url_title_char_45432'    =>  "Noh",      // Korean Letter 노
'url_title_char_45453'    =>  "Nong",      // Korean Letter 농
'url_title_char_45516'    =>  "Noe",      // Korean Letter 뇌
'url_title_char_45544'    =>  "Neung",      // Korean Letter 뇨
'url_title_char_45768'    =>  "Ni",      // Korean Letter 니

the convertion should proceed, only Latin capital letters get truncated (just tried on 1.6.8 installation).

In addition, empty url title with English title saves just fine. Only the non-Latin doesn’t save with error at the end.

Correct. But this behavior has nothing to do with URL Title Chars extension. It happens because convertion into Latin characters is done client-side. If you send English title, then conversion is not needed and url_title is created server-side using title string; if you submit Korean title without url_title then url_title cannot be created server-side using title string and you get an error message.

       
Kim Ryu Hyun's avatar
Kim Ryu Hyun
65 posts
16 years ago
Kim Ryu Hyun's avatar Kim Ryu Hyun

Is there any known extension that conflicts with it?

Because my 1.6.8 system doesn’t seem to work with it.

I have disabled bunch of extionsions but it still doesn’t work.

       
Laisvunas's avatar
Laisvunas
879 posts
16 years ago
Laisvunas's avatar Laisvunas

I don’t know abot any conflicts with other extensions.

Instead of searching for possible conflicts it would be better to look at the source code of Publish page: find in it javascript function liveUrlTitle() and look inside it if you find the lines as this:

if (c == '45392') {NewTextTemp += 'Nyeon'; continue;}
                if (c == '45397') {NewTextTemp += 'Nyeong'; continue;}
                if (c == '45432') {NewTextTemp += 'Noh'; continue;}
                if (c == '45453') {NewTextTemp += 'Nong'; continue;}
                if (c == '45516') {NewTextTemp += 'Noe'; continue;}
                if (c == '45544') {NewTextTemp += 'Neung'; continue;}
                if (c == '45768') {NewTextTemp += 'Ni'; continue;}

If there are such lines, convertion should work.

       
Kim Ryu Hyun's avatar
Kim Ryu Hyun
65 posts
16 years ago
Kim Ryu Hyun's avatar Kim Ryu Hyun

Thanks so much! Laisvunas,

I have disabled all of my extensions and it is working now.

I have to work backup now and find a culprit here.

Your suggestion for Capital Letters getting trucated works like a charm.

       
Laisvunas's avatar
Laisvunas
879 posts
16 years ago
Laisvunas's avatar Laisvunas

If you will find some conflict between URL Title Chars and some other extension, please, report it here.

       
Kim Ryu Hyun's avatar
Kim Ryu Hyun
65 posts
16 years ago
Kim Ryu Hyun's avatar Kim Ryu Hyun

It doesn’t seem to be the extensions after all. I have reinstalled all other extensions and it still works.

I think the problem was that you need to enter some special character before URL Title Chars to start converting. When you enter consecutive Korean characters only, it does nothing but when you press something like ‘space’ or ‘!’ character then it starts to convert.

This is why I originally thought that it wasn’t working. It would be great if I can just enter consecutive Korean characters and hit tab to convert but it doesn’t work that way at this point. It doesn’t seem to recognize tab or enter character as an initiation point.

       
Laisvunas's avatar
Laisvunas
879 posts
16 years ago
Laisvunas's avatar Laisvunas
I think the problem was that you need to enter some special character before URL Title Chars to start converting.

When I do copy/paste with Korean characters, the conversion proceeds correctly. I don’t know how to input Korean characters from keyboard :(

       
1 2

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.