speakingurl-rails 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 926ae78bd3b5c4eea1e9d7053ca6f5687fdbb05d
4
+ data.tar.gz: cf0e12dd3eae869eb84a09cc7e97ca941898e85d
5
+ SHA512:
6
+ metadata.gz: ea104aedda79de3e95a92689d4c37018725182d4bc80f56491779a56c4f9d835eb66bb5d628a19ab6ddb0ea270c8658c5069fb7635813d6bbda452759575132a
7
+ data.tar.gz: 4d1909ad41ed6dc5c024bccee603b1bece1af2267100c05ec5c054c3e3112dceab12a74a9615876b886c67de95e2ae6e789ec154e44e63d6dc85c51dc02c454a
data/LICENSE ADDED
@@ -0,0 +1,12 @@
1
+ The BSD 3-Clause License (BSD3)
2
+
3
+ Copyright (c) 2013-2015 Sascha Droste <pid@posteo.net>
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
7
+
8
+ * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
9
+ * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
10
+ * Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
11
+
12
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.md ADDED
@@ -0,0 +1,382 @@
1
+ # SpeakingURL
2
+ [![Package Quality](http://npm.packagequality.com/badge/speakingurl.png)](http://packagequality.com/#?package=speakingurl)
3
+
4
+ [![NPM version](https://badge.fury.io/js/speakingurl.png)](http://badge.fury.io/js/speakingurl) [![Build Status](https://travis-ci.org/pid/speakingurl.png)](https://travis-ci.org/pid/speakingurl) [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/pid/speakingurl?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
5
+ ================================================================================================================================================================================================================================================================================================================================================================
6
+
7
+ > Generate a slug with a lot of options; create of so called 'static' or 'Clean URL' or 'Pretty URL' or 'nice-looking URL' or 'Speaking URL' or 'user-friendly URL' or 'SEO-friendly URL' from a string. This module aims to transliterate the input string.
8
+
9
+ For use in browser and server - no dependencies!
10
+
11
+ ###### Notes
12
+
13
+ Never use the slug to reference to the unique page in the database – if the title will change, you want to change the slug – you run into problems.
14
+
15
+ 1. Use a unique reference to the record – e.g. a unique key "12345" =\> /my-little-title-12345.html
16
+ 2. Store all historical slugs in the page record; but you have to re-calculate the slug from all pages – every time you update speakingurl
17
+
18
+ Redirect with 301 to the last/current slug.
19
+
20
+ ##### NPM Badge
21
+
22
+ [![Module Status](https://nodei.co/npm/speakingurl.png?downloads=true&stars=true)](https://npmjs.org/package/speakingurl)
23
+
24
+ Installation
25
+ ------------
26
+
27
+ #### [npm](https://npmjs.org/package/speakingurl)
28
+
29
+ ```shell
30
+ npm install speakingurl --save
31
+ ```
32
+
33
+ #### [Bower](http://bower.io)
34
+
35
+ ```shell
36
+ bower install --save speakingurl
37
+ ```
38
+
39
+ #### [Component](https://github.com/component/component)
40
+
41
+ ```shell
42
+ component install pid/speakingurl
43
+ ```
44
+
45
+ #### [jamjs](http://jamjs.org/)
46
+
47
+ ```shell
48
+ jam install speakingurl
49
+ ```
50
+
51
+ #### [Ruby on Rails](http://rubyonrails.org/)
52
+
53
+ ```ruby
54
+ # Add to Gemfile
55
+ gem 'speakingurl-rails'
56
+ ```
57
+
58
+ ```ruby
59
+ # Add to application.js
60
+ //= require speakingurl
61
+ ```
62
+
63
+ #### [Download Package](https://github.com/pid/speakingurl/releases)
64
+
65
+ copy the file speakingurl.min.js to your script directory
66
+
67
+ #### [CDN/cloudflare](https://www.cloudflare.com/)
68
+
69
+ - available versions: http://cdnjs.com/libraries/speakingurl/
70
+ - use //cdnjs.cloudflare.com/ajax/libs/speakingurl/1.1.2/speakingurl.min.js
71
+
72
+ #### [CDN/maxcdn](https://www.maxcdn.com/)
73
+
74
+ - available versions: http://www.jsdelivr.com/#!speakingurl
75
+ - use //cdn.jsdelivr.net/speakingurl/1.1.2/speakingurl.min.js
76
+
77
+ Usage
78
+ -----
79
+
80
+ ### getSlug(input, [options]);
81
+
82
+ `input`: {string} to convert
83
+
84
+ `options` {object|string} config object or separator string (see below)
85
+
86
+ - `options` {object}
87
+
88
+ - `separator` {string} default: '-'
89
+ - char that replace the whitespaces
90
+ - `lang` {string} default: 'en'
91
+ - false -> don't convert symbols
92
+ - language for symbol translation ('ar', 'cz', 'de', 'en', 'es', 'fr', 'hu', 'it', 'my, 'nl', pt', 'ru', 'sk', 'tr' and 'vn'; more coming soon, please help!)
93
+ - false -\> don't convert symbols
94
+ - `maintainCase` {boolean} default: false
95
+ - true -\> maintain case chars
96
+ - false -\> convert all chars to lower case
97
+ - `titleCase` {boolean|array} default: false
98
+ - true -\> convert input string to title-case
99
+ - array -\> titlecase = true, but omit the words from in the array
100
+ - `truncate` {number} default: 0
101
+ - 0 -\> don't trim length
102
+ - \>= 1 -\> trim to max length while not breaking any words
103
+ - `uric` {boolean} default: false
104
+ - true -\> additionally allow chars: ";", "?", ":", "@", "&", "=", "+", "\$", ",", "/"
105
+ - false
106
+ - `uricNoSlash` {boolean} default: false
107
+ - true -\> additionally allow chars: ";", "?", ":", "@", "&", "=", "+", "\$", ","
108
+ - `mark` {boolean} default: false
109
+ - true -\> additionally allow chars: "-", "\_", ".", "!", "~", "\*", "'", "(", ")"
110
+ - `custom` {object|array} default: {}
111
+ - object -\> custom map for translation, overwrites all i.e. { '&': '\#', '\*': ' star ' }
112
+ - array -\> add chars to allowed charMap (see example)
113
+
114
+ - `options` {string} separator
115
+
116
+ notes: default only Base64 chars are allowed (/A-Za-z0-9\_-/), setting `uric`, `uricNoSlash` or/and `mark` to `true` will add the specified chars to the list of allowed characters. The separator-character is always allowed.
117
+
118
+ ##### Node.js
119
+
120
+ ```js
121
+ var getSlug = require('speakingurl');
122
+ ```
123
+
124
+ ##### Browser
125
+
126
+ ```html
127
+ <script src="bower_components/speakingurl/speakingurl.min.js"></script>
128
+ ```
129
+
130
+ #### Examples
131
+
132
+ ```js
133
+ var slug;
134
+
135
+ slug = getSlug("Schöner Titel läßt grüßen!? Bel été !");
136
+ console.log(slug); // Output: schoener-titel-laesst-gruessen-bel-ete
137
+
138
+ slug = getSlug("Schöner Titel läßt grüßen!? Bel été !", '*');
139
+ console.log(slug); // Output: schoener*titel*laesst*gruessen*bel*ete
140
+
141
+ slug = getSlug("Schöner Titel läßt grüßen!? Bel été !", {
142
+ separator: '_'
143
+ });
144
+ console.log(slug); // Output: schoener_titel_laesst_gruessen_bel_ete
145
+
146
+ slug = getSlug("Schöner Titel läßt grüßen!? Bel été !", {
147
+ uric: true
148
+ });
149
+ console.log(slug); // Output: schoener-titel-laesst-gruessen?-bel-ete
150
+
151
+ slug = getSlug("Schöner Titel läßt grüßen!? Bel été !", {
152
+ uricNoSlash: true
153
+ });
154
+ console.log(slug); // Output: schoener-titel-laesst-gruessen?-bel-ete
155
+
156
+ slug = getSlug("Schöner Titel läßt grüßen!? Bel été !", {
157
+ mark: true
158
+ });
159
+ console.log(slug); // Output: schoener-titel-laesst-gruessen!-bel-ete-!
160
+
161
+ slug = getSlug("Schöner Titel läßt grüßen!? Bel été !", {
162
+ truncate: 20
163
+ });
164
+ console.log(slug); // Output: schoener-titel
165
+
166
+ slug = getSlug("Schöner Titel läßt grüßen!? Bel été !", {
167
+ maintainCase: true
168
+ });
169
+ console.log(slug); // Output: Schoener-Titel-laesst-gruessen-Bel-ete
170
+
171
+ slug = getSlug("Äpfel & Birnen!", {
172
+ lang: 'de'
173
+ });
174
+ console.log(slug); // Output: aepfel-und-birnen
175
+
176
+ slug = getSlug("မြန်မာ သာဓက", {
177
+ lang: 'my'
178
+ });
179
+ console.log(slug); // Output: myanma-thadak
180
+
181
+ slug = getSlug("Apple & Pear!", {
182
+ lang: 'en' // lang: "en" is default, just to clarify
183
+ });
184
+ console.log(slug); // Output: apple-and-pear
185
+
186
+ slug = getSlug('Foo & Bar * Baz', {
187
+ custom: {
188
+ '&': ' doo '
189
+ },
190
+ uric:true
191
+ });
192
+ console.log(slug); // Output: foo-doo-bar-baz
193
+
194
+ slug = getSlug('Foo ♥ Bar');
195
+ console.log(slug); // Output: foo-love-bar
196
+
197
+ slug = getSlug('Foo & Bar | (Baz) * Doo', {
198
+ custom: {
199
+ '*': 'Boo'
200
+ },
201
+ mark:true
202
+ });
203
+ console.log(slug); // Output: foo-and-bar-or-(baz)-boo-doo
204
+
205
+ slug = getSlug('Foo and Bar or Baz', {
206
+ custom: {
207
+ 'and': 'und',
208
+ 'or': ''
209
+ }
210
+ });
211
+ console.log(slug); // Output: foo-und-bar-baz
212
+
213
+ slug = getSlug('[Knöpfe]', {
214
+ custom: [
215
+ '[',
216
+ ']'
217
+ ]
218
+ });
219
+ console.log(slug); // Output: [knoepfe]
220
+
221
+ slug = getSlug('NEXUS4 only $299');
222
+ console.log(slug); // Output: nexus-4-only-usd299
223
+
224
+ slug = getSlug('NEXUS4 only €299', {
225
+ maintainCase: true
226
+ });
227
+ console.log(slug); // Output: NEXUS-4-only-EUR299
228
+
229
+ slug = getSlug('Don\'t drink and drive', {
230
+ titleCase: true
231
+ });
232
+ console.log(slug); // Output: Don-t-Drink-And-Drive
233
+
234
+ slug = getSlug('Don\'t drink and drive', {
235
+ titleCase: ['and']
236
+ });
237
+ console.log(slug); // Output: Don-t-Drink-and-Drive
238
+
239
+ slug = getSlug('Foo & Bar ♥ Foo < Bar', {
240
+ lang: false
241
+ });
242
+ console.log(slug); // Output: foo-bar-foo-bar
243
+ ```
244
+
245
+ ### createSlug([options])
246
+
247
+ `options`: {object|string} config object or separator string (see above)
248
+
249
+ Create your own specially configured function.
250
+
251
+ ```js
252
+ var options = {
253
+ maintainCase: true,
254
+ separator: '_'
255
+ };
256
+
257
+ var mySlug = require('speakingurl').createSlug(options);
258
+ // in browser:
259
+ // var mySlug = createSlug(options);
260
+
261
+ var slug = mySlug("Schöner Titel läßt grüßen!? Bel été !");
262
+ console.log(slug); // Output: Schoener_Titel_laesst_gruessen_Bel_ete
263
+ ```
264
+
265
+ Create your own specially configured function with title-case feature.
266
+
267
+ ```js
268
+ var options = {
269
+ titleCase: [
270
+ "a","an","and","as","at","but",
271
+ "by","en","for","if","in","nor",
272
+ "of","on","or","per","the","to","vs"
273
+ ]
274
+ };
275
+
276
+ var mySlug = require('speakingurl').createSlug(options);
277
+ // in browser:
278
+ // var mySlug = createSlug(options);
279
+
280
+ var slug = mySlug('welcome to the jungle');
281
+ console.log(slug); // Output: Welcome-to-the-Jungle
282
+ ```
283
+
284
+ Changelog
285
+ ---------
286
+
287
+ see [CHANGELOG.md](https://raw.github.com/pid/speakingurl/master/CHANGELOG.md)
288
+
289
+ Tests
290
+ -----
291
+
292
+ [![Build Status](https://travis-ci.org/pid/speakingurl.png)](https://travis-ci.org/pid/speakingurl)
293
+
294
+ ```shell
295
+ npm test
296
+ ```
297
+
298
+ Contribution
299
+ ------------
300
+
301
+ ```shell
302
+
303
+ # fork pid/speakingurl on Github
304
+ $ git clone git@github.com:<YOUR_USER>/speakingurl.git
305
+ $ cd speakingurl
306
+ $ npm install
307
+ # add your stuff
308
+ # add tests
309
+ # add example for new feature
310
+ # add release info to CHANGELOG.md
311
+ # add description/example to README.md
312
+ $ gulp
313
+ $ commit files (speakingurl.min.js,...)
314
+ # if everything works fine, commit, push to your repository
315
+ # create pull request
316
+
317
+ # release new version / only for maintainer
318
+ $ gulp bumpup --minor
319
+ $ gulp release
320
+
321
+
322
+ $
323
+ ```
324
+
325
+ Release
326
+ -------
327
+
328
+ ```shell
329
+ $ gulp bumpup --patch
330
+ $ gulp
331
+ $ gulp release
332
+ ```
333
+
334
+ Release to RubyGems.org
335
+ -----------------------
336
+
337
+ ```shell
338
+ $ gulp
339
+ $ gem build speakingurl-rails.gemspec
340
+ $ gem push speakingurl-rails-x.x.x.gem
341
+ ```
342
+
343
+ [![Flattr](http://api.flattr.com/button/flattr-badge-large.png)](http://flattr.com/thing/1418477/pidspeakingurl-on-GitHub)
344
+
345
+ References
346
+ ----------
347
+
348
+ - http://tools.ietf.org/html/rfc3986
349
+ - http://en.wikipedia.org/wiki/Transliteration
350
+
351
+ Use in other environments
352
+ -------------------------
353
+
354
+ - [SpeakingURL with AngularJS](https://github.com/zappan/angular-speakingurl)
355
+ - [SpeakingURL with Meteor](https://github.com/ongoworks/meteor-speakingurl)
356
+
357
+ Ports
358
+ -----
359
+
360
+ - Java https://github.com/Weltraumschaf/speakingurl thanks to[@Weltraumschaf](https://github.com/Weltraumschaf/)
361
+
362
+ Credits
363
+ -------
364
+
365
+ - [@dypsilon](https://github.com/dypsilon/)
366
+ - [@simov](https://github.com/simov/)
367
+ - [@henrikjoreteg](https://github.com/henrikjoreteg/)
368
+
369
+ [License](https://raw.github.com/pid/speakingurl/master/LICENSE)
370
+ ----------------------------------------------------------------
371
+
372
+ The BSD 3-Clause License (BSD3)
373
+
374
+ Copyright (c) 2013-2015 Sascha Droste pid@posteo.net All rights reserved.
375
+
376
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
377
+
378
+ - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
379
+ - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
380
+ - Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
381
+
382
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,12 @@
1
+ require 'rails'
2
+
3
+ module Speakingurl
4
+ module Rails
5
+ class Railtie < ::Rails::Railtie
6
+ initializer "speakingurl_rails.append_path", :group => :all do |app|
7
+ speakingurl_path = File.expand_path('../', __FILE__)
8
+ app.assets.prepend_path(speakingurl_path.to_s)
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,1143 @@
1
+ (function (root) {
2
+ 'use strict';
3
+
4
+ /**
5
+ * getSlug
6
+ * @param {string} input input string
7
+ * @param {object|string} opts config object or separator string/char
8
+ * @api public
9
+ * @return {string} sluggified string
10
+ */
11
+ var getSlug = function getSlug(input, opts) {
12
+
13
+ var maintainCase = (typeof opts === 'object' && opts.maintainCase) || false;
14
+ var titleCase;
15
+ var customReplacements = (typeof opts === 'object' && typeof opts.custom === 'object' && opts.custom) ? opts.custom : {};
16
+ var separator = (typeof opts === 'object' && opts.separator) || '-';
17
+ var truncate = (typeof opts === 'object' && +opts.truncate > 1 && opts.truncate) || false;
18
+ var uricFlag = (typeof opts === 'object' && opts.uric) || false;
19
+ var uricNoSlashFlag = (typeof opts === 'object' && opts.uricNoSlash) || false;
20
+ var markFlag = (typeof opts === 'object' && opts.mark) || false;
21
+ var symbol = (typeof opts === 'object' && opts.lang && symbolMap[opts.lang]) ?
22
+ symbolMap[opts.lang] :
23
+ (typeof opts === 'object' && (opts.lang === false || opts.lang === true) ? {} : symbolMap.en);
24
+ var langChar = (typeof opts === 'object' && opts.lang && langCharMap[opts.lang]) ?
25
+ langCharMap[opts.lang] :
26
+ (typeof opts === 'object' && (opts.lang === false || opts.lang === true) ? {} : langCharMap.en);
27
+ var uricChars = [';', '?', ':', '@', '&', '=', '+', '$', ',', '/'];
28
+ var uricNoSlashChars = [';', '?', ':', '@', '&', '=', '+', '$', ','];
29
+ var markChars = ['.', '!', '~', '*', '\'', '(', ')'];
30
+ var result = '';
31
+ var diatricString = '';
32
+ var lucky;
33
+ var allowedChars = separator;
34
+ var i;
35
+ var ch;
36
+ var l;
37
+ var lastCharWasSymbol;
38
+ var lastCharWasDiatric;
39
+
40
+ // if titleCase config is an Array, rewrite to object format
41
+ if (typeof opts === 'object' && opts.titleCase && typeof opts.titleCase.length === "number" && Array.prototype.toString.call(opts.titleCase)) {
42
+
43
+ opts.titleCase.forEach(function (v) {
44
+ customReplacements[v + ""] = v + "";
45
+ });
46
+
47
+ titleCase = true;
48
+ } else {
49
+ titleCase = typeof opts === 'object' && !!opts.titleCase;
50
+ }
51
+
52
+ // if custom config is an Array, rewrite to object format
53
+ if (typeof opts === 'object' && opts.custom && typeof opts.custom.length === "number" && Array.prototype.toString.call(opts.custom)) {
54
+
55
+ opts.custom.forEach(function (v) {
56
+ customReplacements[v + ""] = v + "";
57
+ });
58
+ }
59
+
60
+ if (typeof input !== 'string') {
61
+ return '';
62
+ }
63
+
64
+ if (typeof opts === 'string') {
65
+ separator = opts;
66
+ } else if (typeof opts === 'object') {
67
+
68
+ if (uricFlag) {
69
+ allowedChars += uricChars.join('');
70
+ }
71
+
72
+ if (uricNoSlashFlag) {
73
+ allowedChars += uricNoSlashChars.join('');
74
+ }
75
+
76
+ if (markFlag) {
77
+ allowedChars += markChars.join('');
78
+ }
79
+ }
80
+
81
+ // custom replacements
82
+ Object.keys(customReplacements).forEach(function (v) {
83
+
84
+ var r;
85
+
86
+ if (v.length > 1) {
87
+ r = new RegExp('\\b' + escapeChars(v) + '\\b', 'gi');
88
+ } else {
89
+ r = new RegExp(escapeChars(v), 'gi');
90
+ }
91
+
92
+ input = input.replace(r, customReplacements[v]);
93
+ });
94
+
95
+ // add all custom replacement to allowed charlist
96
+
97
+ for (ch in customReplacements) {
98
+ allowedChars += ch;
99
+ }
100
+
101
+ if (titleCase) {
102
+
103
+ input = input.replace(/(\w)(\S*)/g, function (_, i, r) {
104
+ var j = i.toUpperCase() + (r !== null ? r : "");
105
+ return (Object.keys(customReplacements).indexOf(j.toLowerCase()) < 0) ? j : j.toLowerCase();
106
+ });
107
+ }
108
+
109
+ // escape all necessary chars
110
+ allowedChars = escapeChars(allowedChars);
111
+
112
+ // trim whitespaces
113
+ input = input.replace(/(^\s+|\s+$)/g, '');
114
+
115
+ lastCharWasSymbol = false;
116
+ lastCharWasDiatric = false;
117
+
118
+ for (i = 0, l = input.length; i < l; i++) {
119
+
120
+ ch = input[i];
121
+
122
+ if (isReplacedCustomChar(ch, customReplacements)) {
123
+ // don't convert a already converted char
124
+ lastCharWasSymbol = false;
125
+ } else if (langChar[ch]) {
126
+ // process language specific diactrics chars conversion
127
+ ch = lastCharWasSymbol && langChar[ch].match(/[A-Za-z0-9]/) ? ' ' + langChar[ch] : langChar[ch];
128
+
129
+ lastCharWasSymbol = false;
130
+ } else if (ch in charMap) {
131
+ // the transliteration changes entirely when some special characters are added
132
+ if (i + 1 < l && lookAheadCharArray.indexOf(input[i + 1]) >= 0) {
133
+ diatricString += ch;
134
+ ch = '';
135
+ } else if (lastCharWasDiatric === true) {
136
+ ch = diatricMap[diatricString] + charMap[ch];
137
+ diatricString = '';
138
+ } else {
139
+ // process diactrics chars
140
+ ch = lastCharWasSymbol && charMap[ch].match(/[A-Za-z0-9]/) ? ' ' + charMap[ch] : charMap[ch];
141
+ }
142
+
143
+ lastCharWasSymbol = false;
144
+ lastCharWasDiatric = false;
145
+ } else if (ch in diatricMap) {
146
+ diatricString += ch;
147
+ ch = '';
148
+ // end of string, put the whole meaningful word
149
+ if (i === l - 1) {
150
+ ch = diatricMap[diatricString];
151
+ }
152
+ lastCharWasDiatric = true;
153
+ } else if (
154
+ // process symbol chars
155
+ symbol[ch] && !(uricFlag && uricChars.join('')
156
+ .indexOf(ch) !== -1) && !(uricNoSlashFlag && uricNoSlashChars.join('')
157
+ .indexOf(ch) !== -1) && !(markFlag && markChars.join('')
158
+ .indexOf(ch) !== -1)) {
159
+
160
+ ch = lastCharWasSymbol || result.substr(-1).match(/[A-Za-z0-9]/) ? separator + symbol[ch] : symbol[ch];
161
+ ch += input[i + 1] !== void 0 && input[i + 1].match(/[A-Za-z0-9]/) ? separator : '';
162
+
163
+ lastCharWasSymbol = true;
164
+ } else {
165
+ if (lastCharWasDiatric === true) {
166
+ ch = diatricMap[diatricString] + ch;
167
+ diatricString = '';
168
+ lastCharWasDiatric = false;
169
+ } else if (lastCharWasSymbol && (/[A-Za-z0-9]/.test(ch) || result.substr(-1).match(/A-Za-z0-9]/))) {
170
+ // process latin chars
171
+ ch = ' ' + ch;
172
+ }
173
+ lastCharWasSymbol = false;
174
+ }
175
+
176
+ // add allowed chars
177
+ result += ch.replace(new RegExp('[^\\w\\s' + allowedChars + '_-]', 'g'), separator);
178
+ }
179
+
180
+ // eliminate duplicate separators
181
+ // add separator
182
+ // trim separators from start and end
183
+ result = result.replace(/\s+/g, separator)
184
+ .replace(new RegExp('\\' + separator + '+', 'g'), separator)
185
+ .replace(new RegExp('(^\\' + separator + '+|\\' + separator + '+$)', 'g'), '');
186
+
187
+ if (truncate && result.length > truncate) {
188
+
189
+ lucky = result.charAt(truncate) === separator;
190
+ result = result.slice(0, truncate);
191
+
192
+ if (!lucky) {
193
+ result = result.slice(0, result.lastIndexOf(separator));
194
+ }
195
+ }
196
+
197
+ if (!maintainCase && !titleCase) {
198
+ result = result.toLowerCase();
199
+ }
200
+
201
+ return result;
202
+ };
203
+
204
+ /**
205
+ * createSlug curried(opts)(input)
206
+ * @param {object|string} opts config object or input string
207
+ * @return {Function} function getSlugWithConfig()
208
+ **/
209
+ var createSlug = function createSlug(opts) {
210
+
211
+ /**
212
+ * getSlugWithConfig
213
+ * @param {string} input string
214
+ * @return {string} slug string
215
+ */
216
+ return function getSlugWithConfig(input) {
217
+ return getSlug(input, opts);
218
+ };
219
+ };
220
+
221
+ /**
222
+ * escape Chars
223
+ * @param {string} input string
224
+ */
225
+ var escapeChars = function escapeChars(input) {
226
+
227
+ return input.replace(/[-\\^$*+?.()|[\]{}\/]/g, '\\$&');
228
+ };
229
+
230
+ /**
231
+ * check if the char is an already converted char from custom list
232
+ * @param {char} ch character to check
233
+ * @param {object} customReplacements custom translation map
234
+ */
235
+ var isReplacedCustomChar = function (ch, customReplacements) {
236
+
237
+ for (var c in customReplacements) {
238
+ if (customReplacements[c] === ch) {
239
+ return true;
240
+ }
241
+ }
242
+ };
243
+
244
+ /**
245
+ * charMap
246
+ * @type {Object}
247
+ */
248
+ var charMap = {
249
+
250
+ // latin
251
+ 'À': 'A',
252
+ 'Á': 'A',
253
+ 'Â': 'A',
254
+ 'Ã': 'A',
255
+ 'Ä': 'Ae',
256
+ 'Å': 'A',
257
+ 'Æ': 'AE',
258
+ 'Ç': 'C',
259
+ 'È': 'E',
260
+ 'É': 'E',
261
+ 'Ê': 'E',
262
+ 'Ë': 'E',
263
+ 'Ì': 'I',
264
+ 'Í': 'I',
265
+ 'Î': 'I',
266
+ 'Ï': 'I',
267
+ 'Ð': 'D',
268
+ 'Ñ': 'N',
269
+ 'Ò': 'O',
270
+ 'Ó': 'O',
271
+ 'Ô': 'O',
272
+ 'Õ': 'O',
273
+ 'Ö': 'Oe',
274
+ 'Ő': 'O',
275
+ 'Ø': 'O',
276
+ 'Ù': 'U',
277
+ 'Ú': 'U',
278
+ 'Û': 'U',
279
+ 'Ü': 'Ue',
280
+ 'Ű': 'U',
281
+ 'Ý': 'Y',
282
+ 'Þ': 'TH',
283
+ 'ß': 'ss',
284
+ 'à': 'a',
285
+ 'á': 'a',
286
+ 'â': 'a',
287
+ 'ã': 'a',
288
+ 'ä': 'ae',
289
+ 'å': 'a',
290
+ 'æ': 'ae',
291
+ 'ç': 'c',
292
+ 'è': 'e',
293
+ 'é': 'e',
294
+ 'ê': 'e',
295
+ 'ë': 'e',
296
+ 'ì': 'i',
297
+ 'í': 'i',
298
+ 'î': 'i',
299
+ 'ï': 'i',
300
+ 'ð': 'd',
301
+ 'ñ': 'n',
302
+ 'ò': 'o',
303
+ 'ó': 'o',
304
+ 'ô': 'o',
305
+ 'õ': 'o',
306
+ 'ö': 'oe',
307
+ 'ő': 'o',
308
+ 'ø': 'o',
309
+ 'ù': 'u',
310
+ 'ú': 'u',
311
+ 'û': 'u',
312
+ 'ü': 'ue',
313
+ 'ű': 'u',
314
+ 'ý': 'y',
315
+ 'þ': 'th',
316
+ 'ÿ': 'y',
317
+ 'ẞ': 'SS',
318
+
319
+ // greek
320
+ 'α': 'a',
321
+ 'β': 'v',
322
+ 'γ': 'g',
323
+ 'δ': 'd',
324
+ 'ε': 'e',
325
+ 'ζ': 'z',
326
+ 'η': 'i',
327
+ 'θ': 'th',
328
+ 'ι': 'i',
329
+ 'κ': 'k',
330
+ 'λ': 'l',
331
+ 'μ': 'm',
332
+ 'ν': 'n',
333
+ 'ξ': 'ks',
334
+ 'ο': 'o',
335
+ 'π': 'p',
336
+ 'ρ': 'r',
337
+ 'σ': 's',
338
+ 'τ': 't',
339
+ 'υ': 'y',
340
+ 'φ': 'f',
341
+ 'χ': 'x',
342
+ 'ψ': 'ps',
343
+ 'ω': 'o',
344
+ 'ά': 'a',
345
+ 'έ': 'e',
346
+ 'ί': 'i',
347
+ 'ό': 'o',
348
+ 'ύ': 'y',
349
+ 'ή': 'i',
350
+ 'ώ': 'o',
351
+ 'ς': 's',
352
+ 'ϊ': 'i',
353
+ 'ΰ': 'y',
354
+ 'ϋ': 'y',
355
+ 'ΐ': 'i',
356
+ 'Α': 'A',
357
+ 'Β': 'B',
358
+ 'Γ': 'G',
359
+ 'Δ': 'D',
360
+ 'Ε': 'E',
361
+ 'Ζ': 'Z',
362
+ 'Η': 'I',
363
+ 'Θ': 'TH',
364
+ 'Ι': 'I',
365
+ 'Κ': 'K',
366
+ 'Λ': 'L',
367
+ 'Μ': 'M',
368
+ 'Ν': 'N',
369
+ 'Ξ': 'KS',
370
+ 'Ο': 'O',
371
+ 'Π': 'P',
372
+ 'Ρ': 'R',
373
+ 'Σ': 'S',
374
+ 'Τ': 'T',
375
+ 'Υ': 'Y',
376
+ 'Φ': 'F',
377
+ 'Χ': 'X',
378
+ 'Ψ': 'PS',
379
+ 'Ω': 'W',
380
+ 'Ά': 'A',
381
+ 'Έ': 'E',
382
+ 'Ί': 'I',
383
+ 'Ό': 'O',
384
+ 'Ύ': 'Y',
385
+ 'Ή': 'I',
386
+ 'Ώ': 'O',
387
+ 'Ϊ': 'I',
388
+ 'Ϋ': 'Y',
389
+
390
+ // turkish
391
+ 'ş': 's',
392
+ 'Ş': 'S',
393
+ 'ı': 'i',
394
+ 'İ': 'I',
395
+ // 'ç': 'c', // duplicate
396
+ // 'Ç': 'C', // duplicate
397
+ // 'ü': 'ue', // duplicate, see langCharMap
398
+ // 'Ü': 'Ue', // duplicate, see langCharMap
399
+ // 'ö': 'oe', // duplicate, see langCharMap
400
+ // 'Ö': 'Oe', // duplicate, see langCharMap
401
+ 'ğ': 'g',
402
+ 'Ğ': 'G',
403
+
404
+ // macedonian
405
+ 'Ќ': 'Kj',
406
+ 'ќ': 'kj',
407
+ 'Љ': 'Lj',
408
+ 'љ': 'lj',
409
+ 'Њ': 'Nj',
410
+ 'њ': 'nj',
411
+ 'Тс': 'Ts',
412
+ 'тс': 'ts',
413
+
414
+ // russian
415
+ 'а': 'a',
416
+ 'б': 'b',
417
+ 'в': 'v',
418
+ 'г': 'g',
419
+ 'д': 'd',
420
+ 'е': 'e',
421
+ 'ё': 'yo',
422
+ 'ж': 'zh',
423
+ 'з': 'z',
424
+ 'и': 'i',
425
+ 'й': 'j',
426
+ 'к': 'k',
427
+ 'л': 'l',
428
+ 'м': 'm',
429
+ 'н': 'n',
430
+ 'о': 'o',
431
+ 'п': 'p',
432
+ 'р': 'r',
433
+ 'с': 's',
434
+ 'т': 't',
435
+ 'у': 'u',
436
+ 'ф': 'f',
437
+ 'х': 'h',
438
+ 'ц': 'c',
439
+ 'ч': 'ch',
440
+ 'ш': 'sh',
441
+ 'щ': 'sh',
442
+ 'ъ': '',
443
+ 'ы': 'y',
444
+ 'ь': '',
445
+ 'э': 'e',
446
+ 'ю': 'yu',
447
+ 'я': 'ya',
448
+ 'А': 'A',
449
+ 'Б': 'B',
450
+ 'В': 'V',
451
+ 'Г': 'G',
452
+ 'Д': 'D',
453
+ 'Е': 'E',
454
+ 'Ё': 'Yo',
455
+ 'Ж': 'Zh',
456
+ 'З': 'Z',
457
+ 'И': 'I',
458
+ 'Й': 'J',
459
+ 'К': 'K',
460
+ 'Л': 'L',
461
+ 'М': 'M',
462
+ 'Н': 'N',
463
+ 'О': 'O',
464
+ 'П': 'P',
465
+ 'Р': 'R',
466
+ 'С': 'S',
467
+ 'Т': 'T',
468
+ 'У': 'U',
469
+ 'Ф': 'F',
470
+ 'Х': 'H',
471
+ 'Ц': 'C',
472
+ 'Ч': 'Ch',
473
+ 'Ш': 'Sh',
474
+ 'Щ': 'Sh',
475
+ 'Ъ': '',
476
+ 'Ы': 'Y',
477
+ 'Ь': '',
478
+ 'Э': 'E',
479
+ 'Ю': 'Yu',
480
+ 'Я': 'Ya',
481
+
482
+ // ukranian
483
+ 'Є': 'Ye',
484
+ 'І': 'I',
485
+ 'Ї': 'Yi',
486
+ 'Ґ': 'G',
487
+ 'є': 'ye',
488
+ 'і': 'i',
489
+ 'ї': 'yi',
490
+ 'ґ': 'g',
491
+
492
+ // czech
493
+ 'č': 'c',
494
+ 'ď': 'd',
495
+ 'ě': 'e',
496
+ 'ň': 'n',
497
+ 'ř': 'r',
498
+ 'š': 's',
499
+ 'ť': 't',
500
+ 'ů': 'u',
501
+ 'ž': 'z',
502
+ 'Č': 'C',
503
+ 'Ď': 'D',
504
+ 'Ě': 'E',
505
+ 'Ň': 'N',
506
+ 'Ř': 'R',
507
+ 'Š': 'S',
508
+ 'Ť': 'T',
509
+ 'Ů': 'U',
510
+ 'Ž': 'Z',
511
+
512
+ // slovak
513
+ 'ľ': 'l',
514
+ 'ĺ': 'l',
515
+ 'ŕ': 'r',
516
+ 'Ľ': 'L',
517
+ 'Ĺ': 'L',
518
+ 'Ŕ': 'R',
519
+
520
+ // polish
521
+ 'ą': 'a',
522
+ 'ć': 'c',
523
+ 'ę': 'e',
524
+ 'ł': 'l',
525
+ 'ń': 'n',
526
+ // 'ó': 'o', // duplicate
527
+ 'ś': 's',
528
+ 'ź': 'z',
529
+ 'ż': 'z',
530
+ 'Ą': 'A',
531
+ 'Ć': 'C',
532
+ 'Ę': 'E',
533
+ 'Ł': 'L',
534
+ 'Ń': 'N',
535
+ 'Ś': 'S',
536
+ 'Ź': 'Z',
537
+ 'Ż': 'Z',
538
+
539
+ // latvian
540
+ 'ā': 'a',
541
+ // 'č': 'c', // duplicate
542
+ 'ē': 'e',
543
+ 'ģ': 'g',
544
+ 'ī': 'i',
545
+ 'ķ': 'k',
546
+ 'ļ': 'l',
547
+ 'ņ': 'n',
548
+ // 'š': 's', // duplicate
549
+ 'ū': 'u',
550
+ // 'ž': 'z', // duplicate
551
+ 'Ā': 'A',
552
+ // 'Č': 'C', // duplicate
553
+ 'Ē': 'E',
554
+ 'Ģ': 'G',
555
+ 'Ī': 'I',
556
+ 'Ķ': 'k',
557
+ 'Ļ': 'L',
558
+ 'Ņ': 'N',
559
+ // 'Š': 'S', // duplicate
560
+ 'Ū': 'U',
561
+ // 'Ž': 'Z', // duplicate
562
+
563
+ // Arabic
564
+ 'ا': 'a',
565
+ 'أ': 'a',
566
+ 'إ': 'i',
567
+ 'آ': 'aa',
568
+ 'ؤ': 'u',
569
+ 'ئ': 'e',
570
+ 'ء': 'a',
571
+ 'ب': 'b',
572
+ 'ت': 't',
573
+ 'ث': 'th',
574
+ 'ج': 'j',
575
+ 'ح': 'h',
576
+ 'خ': 'kh',
577
+ 'د': 'd',
578
+ 'ذ': 'th',
579
+ 'ر': 'r',
580
+ 'ز': 'z',
581
+ 'س': 's',
582
+ 'ش': 'sh',
583
+ 'ص': 's',
584
+ 'ض': 'dh',
585
+ 'ط': 't',
586
+ 'ظ': 'z',
587
+ 'ع': 'a',
588
+ 'غ': 'gh',
589
+ 'ف': 'f',
590
+ 'ق': 'q',
591
+ 'ك': 'k',
592
+ 'ل': 'l',
593
+ 'م': 'm',
594
+ 'ن': 'n',
595
+ 'ه': 'h',
596
+ 'و': 'w',
597
+ 'ي': 'y',
598
+ 'ى': 'a',
599
+ 'ة': 'h',
600
+ 'ﻻ': 'la',
601
+ 'ﻷ': 'laa',
602
+ 'ﻹ': 'lai',
603
+ 'ﻵ': 'laa',
604
+
605
+ // Arabic diactrics
606
+ 'َ': 'a',
607
+ 'ً': 'an',
608
+ 'ِ': 'e',
609
+ 'ٍ': 'en',
610
+ 'ُ': 'u',
611
+ 'ٌ': 'on',
612
+ 'ْ': '',
613
+
614
+ // Arabic numbers
615
+ '٠': '0',
616
+ '١': '1',
617
+ '٢': '2',
618
+ '٣': '3',
619
+ '٤': '4',
620
+ '٥': '5',
621
+ '٦': '6',
622
+ '٧': '7',
623
+ '٨': '8',
624
+ '٩': '9',
625
+
626
+ // symbols
627
+ '“': '"',
628
+ '”': '"',
629
+ '‘': '\'',
630
+ '’': '\'',
631
+ '∂': 'd',
632
+ 'ƒ': 'f',
633
+ '™': '(TM)',
634
+ '©': '(C)',
635
+ 'œ': 'oe',
636
+ 'Œ': 'OE',
637
+ '®': '(R)',
638
+ '†': '+',
639
+ '℠': '(SM)',
640
+ '…': '...',
641
+ '˚': 'o',
642
+ 'º': 'o',
643
+ 'ª': 'a',
644
+ '•': '*',
645
+ '၊': ',',
646
+ '။': '.',
647
+
648
+ // currency
649
+ '$': 'USD',
650
+ '€': 'EUR',
651
+ '₢': 'BRN',
652
+ '₣': 'FRF',
653
+ '£': 'GBP',
654
+ '₤': 'ITL',
655
+ '₦': 'NGN',
656
+ '₧': 'ESP',
657
+ '₩': 'KRW',
658
+ '₪': 'ILS',
659
+ '₫': 'VND',
660
+ '₭': 'LAK',
661
+ '₮': 'MNT',
662
+ '₯': 'GRD',
663
+ '₱': 'ARS',
664
+ '₲': 'PYG',
665
+ '₳': 'ARA',
666
+ '₴': 'UAH',
667
+ '₵': 'GHS',
668
+ '¢': 'cent',
669
+ '¥': 'CNY',
670
+ '元': 'CNY',
671
+ '円': 'YEN',
672
+ '﷼': 'IRR',
673
+ '₠': 'EWE',
674
+ '฿': 'THB',
675
+ '₨': 'INR',
676
+ '₹': 'INR',
677
+ '₰': 'PF',
678
+
679
+ // Vietnamese
680
+ 'đ': 'd',
681
+ 'Đ': 'D',
682
+ 'ẹ': 'e',
683
+ 'Ẹ': 'E',
684
+ 'ẽ': 'e',
685
+ 'Ẽ': 'E',
686
+ 'ế': 'e',
687
+ 'Ế': 'E',
688
+ 'ề': 'e',
689
+ 'Ề': 'E',
690
+ 'ệ': 'e',
691
+ 'Ệ': 'E',
692
+ 'ễ': 'e',
693
+ 'Ễ': 'E',
694
+ 'ọ': 'o',
695
+ 'Ọ': 'o',
696
+ 'ố': 'o',
697
+ 'Ố': 'O',
698
+ 'ồ': 'o',
699
+ 'Ồ': 'O',
700
+ 'ộ': 'o',
701
+ 'Ộ': 'O',
702
+ 'ỗ': 'o',
703
+ 'Ỗ': 'O',
704
+ 'ơ': 'o',
705
+ 'Ơ': 'O',
706
+ 'ớ': 'o',
707
+ 'Ớ': 'O',
708
+ 'ờ': 'o',
709
+ 'Ờ': 'O',
710
+ 'ợ': 'o',
711
+ 'Ợ': 'O',
712
+ 'ỡ': 'o',
713
+ 'Ỡ': 'O',
714
+ 'ị': 'i',
715
+ 'Ị': 'I',
716
+ 'ĩ': 'i',
717
+ 'Ĩ': 'I',
718
+ 'ụ': 'u',
719
+ 'Ụ': 'U',
720
+ 'ũ': 'u',
721
+ 'Ũ': 'U',
722
+ 'ư': 'u',
723
+ 'Ư': 'U',
724
+ 'ứ': 'u',
725
+ 'Ứ': 'U',
726
+ 'ừ': 'u',
727
+ 'Ừ': 'U',
728
+ 'ự': 'u',
729
+ 'Ự': 'U',
730
+ 'ữ': 'u',
731
+ 'Ữ': 'U',
732
+ 'ỳ': 'y',
733
+ 'Ỳ': 'Y',
734
+ 'ỵ': 'y',
735
+ 'Ỵ': 'Y',
736
+ 'ỹ': 'y',
737
+ 'Ỹ': 'Y',
738
+ 'ạ': 'a',
739
+ 'Ạ': 'A',
740
+ 'ấ': 'a',
741
+ 'Ấ': 'A',
742
+ 'ầ': 'a',
743
+ 'Ầ': 'A',
744
+ 'ậ': 'a',
745
+ 'Ậ': 'A',
746
+ 'ẫ': 'a',
747
+ 'Ẫ': 'A',
748
+ 'ă': 'a',
749
+ 'Ă': 'A',
750
+ 'ắ': 'a',
751
+ 'Ắ': 'A',
752
+ 'ằ': 'a',
753
+ 'Ằ': 'A',
754
+ 'ặ': 'a',
755
+ 'Ặ': 'A',
756
+ 'ẵ': 'a',
757
+ 'Ẵ': 'A',
758
+
759
+ // burmese consonants
760
+ 'က': 'k',
761
+ 'ခ': 'kh',
762
+ 'ဂ': 'g',
763
+ 'ဃ': 'ga',
764
+ 'င': 'ng',
765
+ 'စ': 's',
766
+ 'ဆ': 'sa',
767
+ 'ဇ': 'z',
768
+ 'စျ': 'za',
769
+ 'ည': 'ny',
770
+ 'ဋ': 't',
771
+ 'ဌ': 'ta',
772
+ 'ဍ': 'd',
773
+ 'ဎ': 'da',
774
+ 'ဏ': 'na',
775
+ 'တ': 't',
776
+ 'ထ': 'ta',
777
+ 'ဒ': 'd',
778
+ 'ဓ': 'da',
779
+ 'န': 'n',
780
+ 'ပ': 'p',
781
+ 'ဖ': 'pa',
782
+ 'ဗ': 'b',
783
+ 'ဘ': 'ba',
784
+ 'မ': 'm',
785
+ 'ယ': 'y',
786
+ 'ရ': 'ya',
787
+ 'လ': 'l',
788
+ 'ဝ': 'w',
789
+ 'သ': 'th',
790
+ 'ဟ': 'h',
791
+ 'ဠ': 'la',
792
+ 'အ': 'a',
793
+ // consonant character combos
794
+ 'ြ': 'y',
795
+ 'ျ': 'ya',
796
+ 'ွ': 'w',
797
+ 'ြွ': 'yw',
798
+ 'ျွ': 'ywa',
799
+ 'ှ': 'h',
800
+ // independent vowels
801
+ 'ဧ': 'e',
802
+ '၏': '-e',
803
+ 'ဣ': 'i',
804
+ 'ဤ': '-i',
805
+ 'ဉ': 'u',
806
+ 'ဦ': '-u',
807
+ 'ဩ': 'aw',
808
+ 'သြော': 'aw',
809
+ 'ဪ': 'aw',
810
+ // numbers
811
+ '၀': '0',
812
+ '၁': '1',
813
+ '၂': '2',
814
+ '၃': '3',
815
+ '၄': '4',
816
+ '၅': '5',
817
+ '၆': '6',
818
+ '၇': '7',
819
+ '၈': '8',
820
+ '၉': '9',
821
+ // virama and tone marks which are silent in transliteration
822
+ '္': '',
823
+ '့': '',
824
+ 'း': ''
825
+ };
826
+
827
+ /**
828
+ * special look ahead character array
829
+ * These characters form with consonants to become 'single'/consonant combo
830
+ * @type [Array]
831
+ */
832
+ var lookAheadCharArray = [
833
+ // burmese
834
+ '်'
835
+ ];
836
+
837
+ /**
838
+ * diatricMap for languages where transliteration changes entirely as more diatrics are added
839
+ * @type {Object}
840
+ */
841
+ var diatricMap = {
842
+ //burmese
843
+ // dependent vowels
844
+ 'ာ': 'a',
845
+ 'ါ': 'a',
846
+ 'ေ': 'e',
847
+ 'ဲ': 'e',
848
+ 'ိ': 'i',
849
+ 'ီ': 'i',
850
+ 'ို': 'o',
851
+ 'ု': 'u',
852
+ 'ူ': 'u',
853
+ 'ေါင်': 'aung',
854
+ 'ော': 'aw',
855
+ 'ော်': 'aw',
856
+ 'ေါ': 'aw',
857
+ 'ေါ်': 'aw',
858
+ '်': '်', // this is special case but the character will be converted to latin in the code
859
+ 'က်': 'et',
860
+ 'ိုက်': 'aik',
861
+ 'ောက်': 'auk',
862
+ 'င်': 'in',
863
+ 'ိုင်': 'aing',
864
+ 'ောင်': 'aung',
865
+ 'စ်': 'it',
866
+ 'ည်': 'i',
867
+ 'တ်': 'at',
868
+ 'ိတ်': 'eik',
869
+ 'ုတ်': 'ok',
870
+ 'ွတ်': 'ut',
871
+ 'ေတ်': 'it',
872
+ 'ဒ်': 'd',
873
+ 'ိုဒ်': 'ok',
874
+ 'ုဒ်': 'ait',
875
+ 'န်': 'an',
876
+ 'ာန်': 'an',
877
+ 'ိန်': 'ein',
878
+ 'ုန်': 'on',
879
+ 'ွန်': 'un',
880
+ 'ပ်': 'at',
881
+ 'ိပ်': 'eik',
882
+ 'ုပ်': 'ok',
883
+ 'ွပ်': 'ut',
884
+ 'န်ုပ်': 'nub',
885
+ 'မ်': 'an',
886
+ 'ိမ်': 'ein',
887
+ 'ုမ်': 'on',
888
+ 'ွမ်': 'un',
889
+ 'ယ်': 'e',
890
+ 'ိုလ်': 'ol',
891
+ 'ဉ်': 'in',
892
+ 'ံ': 'an',
893
+ 'ိံ': 'ein',
894
+ 'ုံ': 'on'
895
+ };
896
+
897
+ /**
898
+ * langCharMap language specific characters translations
899
+ * @type {Object}
900
+ */
901
+ var langCharMap = {
902
+ 'en': {}, // default language
903
+ 'hu': {
904
+ 'ä': 'a', // ok
905
+ 'Ä': 'A', // ok
906
+ // 'á': 'a', duplicate see charMap/latin
907
+ // 'Á': 'A', duplicate see charMap/latin
908
+ 'ö': 'o', // ok
909
+ 'Ö': 'O', // ok
910
+ // 'ő': 'o', duplicate see charMap/latin
911
+ // 'Ő': 'O', duplicate see charMap/latin
912
+ 'ü': 'u',
913
+ 'Ü': 'U',
914
+ 'ű': 'u',
915
+ 'Ű': 'U'
916
+ },
917
+ 'sk': {
918
+ 'ä': 'a',
919
+ 'Ä': 'A'
920
+ },
921
+ 'tr': {
922
+ 'Ü': 'U',
923
+ 'Ö': 'O',
924
+ 'ü': 'u',
925
+ 'ö': 'o'
926
+ }
927
+ };
928
+
929
+ /**
930
+ * symbolMap language specific symbol translations
931
+ * translations must be transliterated already
932
+ * @type {Object}
933
+ */
934
+ var symbolMap = {
935
+
936
+ 'ar': {
937
+ '∆': 'delta',
938
+ '∞': 'la-nihaya',
939
+ '♥': 'hob',
940
+ '&': 'wa',
941
+ '|': 'aw',
942
+ '<': 'aqal-men',
943
+ '>': 'akbar-men',
944
+ '∑': 'majmou',
945
+ '¤': 'omla'
946
+ },
947
+
948
+ 'cz': {
949
+ '∆': 'delta',
950
+ '∞': 'nekonecno',
951
+ '♥': 'laska',
952
+ '&': 'a',
953
+ '|': 'nebo',
954
+ '<': 'mene jako',
955
+ '>': 'vice jako',
956
+ '∑': 'soucet',
957
+ '¤': 'mena'
958
+ },
959
+
960
+ 'de': {
961
+ '∆': 'delta',
962
+ '∞': 'unendlich',
963
+ '♥': 'Liebe',
964
+ '&': 'und',
965
+ '|': 'oder',
966
+ '<': 'kleiner als',
967
+ '>': 'groesser als',
968
+ '∑': 'Summe von',
969
+ '¤': 'Waehrung'
970
+ },
971
+
972
+ 'en': {
973
+ '∆': 'delta',
974
+ '∞': 'infinity',
975
+ '♥': 'love',
976
+ '&': 'and',
977
+ '|': 'or',
978
+ '<': 'less than',
979
+ '>': 'greater than',
980
+ '∑': 'sum',
981
+ '¤': 'currency'
982
+ },
983
+
984
+ 'es': {
985
+ '∆': 'delta',
986
+ '∞': 'infinito',
987
+ '♥': 'amor',
988
+ '&': 'y',
989
+ '|': 'u',
990
+ '<': 'menos que',
991
+ '>': 'mas que',
992
+ '∑': 'suma de los',
993
+ '¤': 'moneda'
994
+ },
995
+
996
+ 'fr': {
997
+ '∆': 'delta',
998
+ '∞': 'infiniment',
999
+ '♥': 'Amour',
1000
+ '&': 'et',
1001
+ '|': 'ou',
1002
+ '<': 'moins que',
1003
+ '>': 'superieure a',
1004
+ '∑': 'somme des',
1005
+ '¤': 'monnaie'
1006
+ },
1007
+
1008
+ 'hu': {
1009
+ '∆': 'delta',
1010
+ '∞': 'vegtelen',
1011
+ '♥': 'szerelem',
1012
+ '&': 'es',
1013
+ '|': 'vagy',
1014
+ '<': 'kisebb mint',
1015
+ '>': 'nagyobb mint',
1016
+ '∑': 'szumma',
1017
+ '¤': 'penznem'
1018
+ },
1019
+
1020
+ 'my': {
1021
+ '∆': 'kwahkhyaet',
1022
+ '∞': 'asaonasme',
1023
+ '♥': 'akhyait',
1024
+ '&': 'nhin',
1025
+ '|': 'tho',
1026
+ '<': 'ngethaw',
1027
+ '>': 'kyithaw',
1028
+ '∑': 'paungld',
1029
+ '¤': 'ngwekye'
1030
+ },
1031
+
1032
+ 'nl': {
1033
+ '∆': 'delta',
1034
+ '∞': 'oneindig',
1035
+ '♥': 'liefde',
1036
+ '&': 'en',
1037
+ '|': 'of',
1038
+ '<': 'kleiner dan',
1039
+ '>': 'groter dan',
1040
+ '∑': 'som',
1041
+ '¤': 'valuta'
1042
+ },
1043
+
1044
+ 'it': {
1045
+ '∆': 'delta',
1046
+ '∞': 'infinito',
1047
+ '♥': 'amore',
1048
+ '&': 'e',
1049
+ '|': 'o',
1050
+ '<': 'minore di',
1051
+ '>': 'maggiore di',
1052
+ '∑': 'somma',
1053
+ '¤': 'moneta'
1054
+ },
1055
+
1056
+ 'pt': {
1057
+ '∆': 'delta',
1058
+ '∞': 'infinito',
1059
+ '♥': 'amor',
1060
+ '&': 'e',
1061
+ '|': 'ou',
1062
+ '<': 'menor que',
1063
+ '>': 'maior que',
1064
+ '∑': 'soma',
1065
+ '¤': 'moeda'
1066
+ },
1067
+
1068
+ 'ru': {
1069
+ '∆': 'delta',
1070
+ '∞': 'beskonechno',
1071
+ '♥': 'lubov',
1072
+ '&': 'i',
1073
+ '|': 'ili',
1074
+ '<': 'menshe',
1075
+ '>': 'bolshe',
1076
+ '∑': 'summa',
1077
+ '¤': 'valjuta'
1078
+ },
1079
+
1080
+ 'sk': {
1081
+ '∆': 'delta',
1082
+ '∞': 'nekonecno',
1083
+ '♥': 'laska',
1084
+ '&': 'a',
1085
+ '|': 'alebo',
1086
+ '<': 'menej ako',
1087
+ '>': 'viac ako',
1088
+ '∑': 'sucet',
1089
+ '¤': 'mena'
1090
+ },
1091
+
1092
+ 'tr': {
1093
+ '∆': 'delta',
1094
+ '∞': 'sonsuzluk',
1095
+ '♥': 'ask',
1096
+ '&': 've',
1097
+ '|': 'veya',
1098
+ '<': 'kucuktur',
1099
+ '>': 'buyuktur',
1100
+ '∑': 'toplam',
1101
+ '¤': 'para birimi'
1102
+ },
1103
+
1104
+ 'vn': {
1105
+ '∆': 'delta',
1106
+ '∞': 'vo cuc',
1107
+ '♥': 'yeu',
1108
+ '&': 'va',
1109
+ '|': 'hoac',
1110
+ '<': 'nho hon',
1111
+ '>': 'lon hon',
1112
+ '∑': 'tong',
1113
+ '¤': 'tien te'
1114
+ }
1115
+ };
1116
+
1117
+ if (typeof module !== 'undefined' && module.exports) {
1118
+
1119
+ // export functions for use in Node
1120
+ module.exports = getSlug;
1121
+ module.exports.createSlug = createSlug;
1122
+
1123
+ } else if (typeof define !== 'undefined' && define.amd) {
1124
+
1125
+ // export function for use in AMD
1126
+ define([], function () {
1127
+ return getSlug;
1128
+ });
1129
+
1130
+ } else {
1131
+
1132
+ // don't overwrite global if exists
1133
+ try {
1134
+ if (root.getSlug || root.createSlug) {
1135
+ throw 'speakingurl: globals exists /(getSlug|createSlug)/';
1136
+ } else {
1137
+ root.getSlug = getSlug;
1138
+ root.createSlug = createSlug;
1139
+ }
1140
+ } catch (e) {}
1141
+
1142
+ }
1143
+ })(this);