vue-translation-manager icon indicating copy to clipboard operation
vue-translation-manager copied to clipboard

An error if the text contains  

Open impudentem opened this issue 3 years ago • 0 comments

In the console the error looked like this

image

To fix this, I edited this function, which originally looked like this:

/**
 * camelCase any string
 * @param {string} text The string to be camelCased
 * @returns {string} theStringInCamelCase
 */
function camelCase (text) {
  return text
    .trim()
    .split(' ')
    .map((word) => word.toLowerCase())
    .map((word, i) => (i === 0 ? word : word[0].toUpperCase() + word.substring(1)))
    .join('')
}

After my editing, she got this look:

/**
 * camelCase any string
 * @param {string} text The string to be camelCased
 * @returns {string} theStringInCamelCase
 */
function camelCase (text) {
  return text
    .trim()
    .split(' ')
    .map((word) => word.toLowerCase())
    .map((word, i) => (i === 0 && !word[0] ? word : String(word[0]).toUpperCase() + word.substring(1)))
    .join('')
}

And the translation worked successfully. :tada::tada::tada:

impudentem avatar Dec 17 '21 18:12 impudentem