Coder Social home page Coder Social logo

Multilanguage support about consentcookie HOT 8 CLOSED

StevenChoo avatar StevenChoo commented on June 2, 2024 1
Multilanguage support

from consentcookie.

Comments (8)

StevenChoo avatar StevenChoo commented on June 2, 2024

Example of init with all possible resource keys

<script type="application/javascript">
  ConsentCookie.init({
    'general': {
      'gdpr': {
        'contact': ''
      },
      'consentwall': {
        'enabled': true,
        'timeout': 1000,
      }
    },
    'apps': {
      'endpoint': '',
      'consent': {
        'cc': {
          'initstate': 'optin'
        },
        'iq': {
          'initstate': 'optin'
        },
        'ga': {
          'initstate': 'optin'
        },
        'gtm': {
          'initstate': 'optin'
        }
      }
    },
    'design': {
      'layout': {
        'position': 'right'
      },
      'colorscheme': {
        'primary': '',
        'secondary': '',
      }
    },
    'resources': {
      nl: {
        general: {
          on: 'Aan',
          off: 'Uit',
          close: 'Sluiten',
          moreInfo: 'Meer informatie',
        },
        menu: {
          applications: 'Jouw instellingen',
          about: 'Over ConsentCookie',
          open: 'ConsentCookie openen',
          close: 'ConsentCookie sluiten',
          disabled: 'accepteer eerst',
        },
        applications: {
          title: 'Jouw instellingen',
          moreInfo: 'Meer informatie over deze applicaties',
          moreInfoLink: 'https://www.consentcookie.nl',
          actions: {
            gdpr: 'Recht op...',
          },
          detail: {
            moreInfo: 'Meer informatie over',
            gdprInfo: 'Contact over jouw AVG rechten',
          },
          profile: {
            title: 'Jouw profiel',
            loading: 'Profiel wordt opgehaald',
            noPlugin: 'Deze applicatie heeft geen publiek profiel beschikbaar',
            noProfile: 'Geen profiel beschikbaar',
          },
        },
        about: {
          title: 'Over ConsentCookie',
          text: '', // When empty it takes the default
        },
        consent: {
          title: 'ConsentCookie!',
          text: '', // When empty it takes the default
          button: 'Ok!',
          infolink: 'https://www.consentcookie.nl',
        },
      }
    }
  });
</script>

The nl in the resource stands for the language code. To add a translation for another language add a new resource node with the language code of the chosen language.

<script type="application/javascript">
  ConsentCookie.init({
    resources: {
      'nl': {
        general: {
          on: 'Aan',
          off: 'Uit',
          close: 'Sluiten',
          moreInfo: 'Meer informatie',
        },
      },
      'en-US': {
        general: {
          on: 'On',
          off: 'Off',
          close: 'Close',
          moreInfo: 'More information',
        },
      },
      'de': {
        general: {
          on: 'Auf',
          off: 'Aus',
          close: 'Schließen',
          moreInfo: 'Mehr Informationen',
        },
      },
    }
  });
</script>

(Don`t mind the bad translations)

from consentcookie.

christianvriens avatar christianvriens commented on June 2, 2024

@StevenChoo can you check the questionmarks in this comment.

Tests

Test 1 Check if all fields are changed by filling them in JSON

In Dutch I tested with an extra letter for the first word in the json, so the difference between standard CC and the text in the json would be visible.

  • Are for all the available fields the changes visible.

general:

  • on: 'Aaan',
  • off: 'Uitt',
    ❓ close: 'Sluiiten',
  • moreInfo: 'MMeer info', (gebruikt op Consent pagina voor de infolink)

menu

  • applications: 'jJouw instellingen' (mouseover in menu)
  • about: 'oOver ConsentCookie', (mouseover in menu)
  • open: 'cConsentCookie openen',(mouseover in menu)
  • close: 'cConsentCookie sluiten',(mouseover in menu)
  • disabled: 'aaccepteer eerst',(mouseover in menu)

applications:

actions:

❓ gdpr: 'RRecht op...',

detail:

  • moreInfo: 'MMeer informatie over',
  • gdprInfo: 'CContact over jouw AVG rechten',

profile:

  • title: 'JJouw profiel',
  • loading: 'PProfiel wordt opgehaald',
  • noPlugin: 'DDeze applicatie heeft geen publiek profiel beschikbaar',
  • noProfile: 'GGeen profiel beschikbaar',

about:

  • title: 'OOver ConsentCookie',
  • text: 'ttext', // When empty it takes the default

consent

Test 2 Change default language in Chrome

  • Does the text change to another language when selecting another default language in Chrome

Test 3 Default language Chrome is not available.

A Only one language

Tested with only Russian in the preferred list

  • Is the default dutch when the preferred chrome language is not available
  • Expect Dutch translation because the preferred language Russian is not available.

B Preferred language not available, second preference 'en-US'

Tested with Russian preferred second 'en-US', third 'de' and fourth 'nl'. Because dutch is the default in the ConsentCookie code I expect this is used in stead of 'en-US'

  • Expect Dutch translation because the preferred language Russian is not available.
    In future the check might take into account that 'en-US' has a higher preference then 'nl'. Should be new improvement.

Test 4 Language doesn't have all the fields

Used 'de' as preferred language, but only filled 4 fields with text.

  • If not all the fields are available in the language are the other fields shown in the default language Dutch

screen shot 2018-06-14 at 14 28 18

Testdata used

Tested this in Chrome by putting a language in the settings advanced on top.
Dutch: nl
English US: en-US
German: de

screen shot 2018-06-14 at 14 35 31

json

<script src="//cdn.humanswitch.services/cc/consentcookie/consentcookie.min.js"></script>
<script type="application/javascript">
    ConsentCookie.init({
        'general': {
            'gdpr': {
                'contact': 'https://www.christianvriens.com'
            },
            'consentwall': {
                'enabled': true,
                'timeout': 1000,
            }
        },
        'apps': {
            'endpoint': '',
            'consent': {
                'cc': {
                    'initstate': 'optin'
                },
                'iq': {
                    'initstate': 'optin'
                },
                'ga': {
                    'initstate': 'optin'
                },
                'gtm': {
                    'initstate': 'optin'
                }
            }
        },
        'design': {
            'layout': {
                'position': 'right'
            },
            'colorscheme': {
                'primary': '',
                'secondary': '',
            }
        },
        'resources': {
            'nl': {
                general: {
                    on: 'Aaan',
                    off: 'Uitt',
                    close: 'Sluiiten',
                    moreInfo: 'MMeer info',
                },
                menu: {
                    applications: 'jJouw instellingen',
                    about: 'oOver ConsentCookie',
                    open: 'cConsentCookie openen',
                    close: 'cConsentCookie sluiten',
                    disabled: 'aaccepteer eerst',
                },
                applications: {
                    title: 'jjJouw instellingen',
                    moreInfo: 'mMeer informatie over deze applicaties',
                    moreInfoLink: 'https://www.consentcookie.eu',
                    actions: {
                        gdpr: 'RRecht op...',
                    },
                    detail: {
                        moreInfo: 'MMeer informatie over',
                        gdprInfo: 'CContact over jouw AVG rechten',
                    },
                    profile: {
                        title: 'JJouw profiel',
                        loading: 'PProfiel wordt opgehaald',
                        noPlugin: 'DDeze applicatie heeft geen publiek profiel beschikbaar',
                        noProfile: 'GGeen profiel beschikbaar',
                    },
                },
                about: {
                    title: 'OOver ConsentCookie',
                    text: 'ttext', // When empty it takes the default
                },
                consent: {
                    title: 'CConsentCookie!',
                    text: 'ttxt', // When empty it takes the default
                    button: 'OOk!',
                    infolink: 'https://www.consentcookie.eu',
                },
            },
            'en-US': {
                general: {
                    on: 'on',
                    off: 'off',
                    close: 'close',
                    moreInfo: 'More more',
                },
                menu: {
                    applications: 'Your configuration',
                    about: 'About CC',
                    open: 'Open CC',
                    close: 'Close CC',
                    disabled: 'First accepts',
                },
                applications: {
                    title: 'Your configuration',
                    moreInfo: 'More info about this app',
                    moreInfoLink: 'https://www.consentcookie.eu',
                    actions: {
                        gdpr: 'Your rights on .. ',
                    },
                    detail: {
                        moreInfo: 'More info',
                        gdprInfo: 'Contact us about your GDPR rights',
                    },
                    profile: {
                        title: 'Your profile',
                        loading: 'Get profile',
                        noPlugin: 'This app doesnt have a public profile',
                        noProfile: 'No profile available',
                    },
                },
                about: {
                    title: 'About CC',
                    text: 'This is en text', // When empty it takes the default
                },
                consent: {
                    title: 'CC!',
                    text: 'this is en text', // When empty it takes the default
                    button: 'Agree!',
                    infolink: 'https://www.consentcookie.eu',
                }
            },'de': {
                general: {
                    on: 'Auf',
                    off: 'Aus',
                    close: 'Schließen',
                    moreInfo: 'Mehr Informationen',
                },
            }
        }
    });
</script>

from consentcookie.

christianvriens avatar christianvriens commented on June 2, 2024

My suggestion with with previous comment: If text with questionmark isn't used remove it.
#47 (comment)

from consentcookie.

christianvriens avatar christianvriens commented on June 2, 2024

@StevenChoo shouldn't the field 'general': 'moreinfo' be with 'consent'?

And if this is changed will existing users still be able to use this in CC?
❓ create improvement issue for this

from consentcookie.

StevenChoo avatar StevenChoo commented on June 2, 2024

@StevenChoo shouldn't the field 'general': 'moreinfo' be with 'consent'?

And if this is changed will existing users still be able to use this in CC?
question create improvement issue for this

Need to check this out

from consentcookie.

StevenChoo avatar StevenChoo commented on June 2, 2024

My suggestion with with previous comment: If text with questionmark isn't used remove it.
#47 (comment)

All text referenced in the config are beeing used. If not its a bug.

from consentcookie.

StevenChoo avatar StevenChoo commented on June 2, 2024

question close: 'Sluiiten',
Removed from default config due to not beeing used.

question gdpr: 'RRecht op...',
Is used for the link shown at every application for requesting GDPR actions. It is only shown when the GDPR option is used

image

question moreInfo: 'mMeer informatie over deze applicaties',
question moreInfoLink: 'https://www.consentcookie.eu',

It seems to be removed since v0.6.0

image

Created issue for this: #58

from consentcookie.

StevenChoo avatar StevenChoo commented on June 2, 2024

Fixed

from consentcookie.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.