Git Product home page Git Product logo

javagrails / grails-locale-configuration-plugin Goto Github PK

View Code? Open in Web Editor NEW

This project forked from stokito/grails-locale-configuration-plugin

0.0 2.0 0.0 389 KB

This plugin intended to control the language support in Grails. Your site may support only few languages. You can allow only supported languages. For example: English, Russian and German, and all other languages should be forced to English.

grails-locale-configuration-plugin's Introduction

Grails Locale Configuration Plugin

[Grails Locale Configuration Plugin] (https://github.com/stokito/grails-locale-configuration-plugin) enhances the handling of Grails localization (i18n).

This plugin is intended to enhance the language support in Grails by detecting your users’ locale and selecting the most appropriate language for them. You can specify a list of supported languages and choose which language to use if a client’s preferred language is not available.

For example, if your site supports only English, Russian and German, you can send users with other locales to the default language (English).

Installation

Please add the following repository and dependency to your BuildConfig.groovy:

grails.project.dependency.resolution = {

    repositories {
        ...
        mavenRepo 'http://dl.bintray.com/stokito/maven'
    }

    ...

    plugins {
        ...
        compile 'name.stokito:grails-locale-configuration-plugin:0.3'
    }

}

Configuration

By default, English and German are defined as supported locales, and English is set as the default locale. If you want to change this, add the following lines to your Config.groovy.

NOTE: The default locale should also be in the list of the supported locales...

name.stokito.smartLocaleResolver.supportedLocales = [Locale.ENGLISH, Locale.GERMAN]
name.stokito.smartLocaleResolver.defaultLocale = Locale.ENGLISH

Locales priority

  1. Language Param in the URL (request), e.g. http://www.example.net?lang=en
  2. First match of the locales from the HTTP Accept-Language header
  3. Default locale (defaultLocale option in Config.groovy)

NOTE: This order is important and cannot be changed. You may want to provide a language selector, so the lang param should have the highest priority.

Take a look into specification for more details

Running application example

Take a look at the demo to see the plugin in action: [Grails Locale Configuration Plugin demo application] (https://github.com/stokito/grails-locale-configuration-plugin-demo)

NOTE: If you want to test your locales (languages), just add the locales to the Config.groovy as descriped in 'Configuration'.

Run demo, like every other Grails application

grails run-app

Application can be accessed by URL http://localhost:8080/

Screenshot of test stand

Support

For any questions feel free to contact me:

Thanks to Barry Norman for contribution.

grails-locale-configuration-plugin's People

Contributors

stokito avatar

Watchers

 avatar  avatar

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.