Locale selector dialog for angular-bootstrap
npm install angular-bootstrap-locale-dialog



Do you want to see dialog in action?
Visit https://sharvit.github.io/angular-bootstrap-locale-dialog/!
Installation is easy as [angular-bootstrap-locale-dialog] has minimal dependencies - only the [AngularJS] and [AngularUI Bootstrap] are required.
Additionally, it is recommended to use some other dependencies:
- [font-awesome] - use to render extra icons for the dialog
- [flag-icon-css] - use to render flag icons for each locale
#### Install with NPM
``sh`
$ npm install angular-bootstrap-locale-dialog --save
This will install [AngularJS] and [AngularUI Bootstrap] NPM packages.
#### Install with Bower
`sh`
$ bower install angular-bootstrap-locale-dialog --save
This will install [AngularJS] and [AngularUI Bootstrap] bower packages.
#### Manual download
All the build files for all version can manually downloaded (or better yet, referencing them from the CDN):
https://sharvit.github.io/angular-bootstrap-locale-dialog//angular-bootstrap-locale-dialog-v1.2.3.js
When you are done downloading all the dependencies and project files the only remaining part is to add dependencies on the angular-bootstrap-locale-dialog [AngularJS] module:
`js`
angular.module('myModule', [
'ui.bootstrap',
'ui.bootstrap.locale-dialog'
]);
[angular-bootstrap-locale-dialog]: http://sharvit.github.io/angular-bootstrap-locale-dialog/
[AngularJS]: https://angularjs.org/
[AngularUI Bootstrap]: https://angular-ui.github.io/bootstrap/
[font-awesome]: https://fortawesome.github.io/Font-Awesome/
[flag-icon-css]: https://lipis.github.io/flag-icon-css/
`html`
You selected: {{vm.selectedLocale}}
`js
angular.module('demo')
.constant("avilableLocales", {
"en-US": {
"name": "English (US)",
"language": "en",
"country": "us"
},
"en-CA": {
"name": "English (CA)",
"language": "en",
"country": "ca"
},
"en-GB": {
"name": "English (GB)",
"language": "en",
"country": "gb"
},
"en-IN": {
"name": "English (IN)",
"language": "en",
"country": "in"
},
"en-IE": {
"name": "English (IE)",
"language": "en",
"country": "ie"
},
"fr-FR": {
"name": "Fran\u00e7ais (FR)",
"language": "fr",
"country": "fr"
},
"fr-BE": {
"name": "Fran\u00e7ais (BE)",
"language": "fr",
"country": "be"
},
"fr-CA": {
"name": "Fran\u00e7ais (CA)",
"language": "fr",
"country": "ca"
},
"fr-LB": {
"name": "Fran\u00e7ais (LB)",
"language": "fr",
"country": "lb"
},
"he-IL": {
"name": "\u05e2\u05d1\u05e8\u05d9\u05ea",
"language": "he",
"country": "il"
},
"pt-BR": {
"name": "Português (BR)",
"language": "pt",
"country": "br"
},
"pt-PT": {
"name": "Português (PT)",
"language": "pt",
"country": "pt"
},
"ro-RO": {
"name": "Română",
"language": "ro",
"country": "ro"
},
"ru-RU": {
"name": "Русский",
"language": "ru",
"country": "ru"
},
"sk-SK": {
"name": "Slovenčina (SK)",
"language": "sk",
"country": "sk"
},
"tr-TR": {
"name": "Türkçe",
"language": "tr",
"country": "tr"
},
"de-DE": {
"name": "Deutsch (German)",
"language": "de",
"country": "de"
},
"th-TH": {
"name": "ภาษาไทย",
"language": "th",
"country": "th"
}
})
.controller('DemoController', function ($localeSelectorDialog, avilableLocales) {
var vm = this;
vm.changeLocale = function () {
$localeSelectorDialog.open({
locales: avilableLocales,
showFlags: true,
showSearch: true,
contributeUrl: 'https://sharvit.github.io/angular-bootstrap-locale-dialog/'
}).result.then(function (selectedLocale) {
vm.selectedLocale = selectedLocale;
});
};
});
`
$localeSelectorDialog is a service to open the locale selector dialog.$uibModal
It based on [AngularUI Bootstrap] witch can create modal windows.
The $localeSelectorDialog service has only one method: open(options).
#### options parameter
* localesobject
_(Type: , Default: {})_ -object
An with all the supported locales of your app.keys
The inside the object should be your locale id, for example: en-USvalue
The for each key should fill the following requirements:name
- string
_(Type: )_ -English (US)
The locale readable name, for example language
- string
_(Type: )_ -en
The language key, for example country
- string
_(Type: )_ -us
The country key, for example
Their is an example for the locale object at the demo.
* templateUrlstring
_(Type: , Default: angular-bootstrap-locale-dialog/angular-bootstrap-locale-dialog.html)_ -showFlags
A path to a template representing modal's content.
Use it if you don't want to use the default template.
* boolean
_(Type: , Default: false)_ -showSearch
Set to true to show flags next to the locale name.
Need to install [flag-icon-css] so it will match the css to the flag icon.
* boolean
_(Type: , Default: false)_ -contributeUrl
Set to true to show the search field.
Useful when you have a big list of locales.
* string
_(Type: , Default: null)_ -
Have a contribute url that your users can help localize your app?
Set it in order to show contribute box with that url.
---
#### return
The open method returns the $uibModal modal instance and use his promise to let you know when the dialog is getting closed and what locale did the user choose.result
You can get the selected locale from the property of the returned $uibModal modal instance.
See the example.
[read more about the $uibModal]
[angular-bootstrap-locale-dialog]: http://sharvit.github.io/angular-bootstrap-locale-dialog/
[AngularJS]: https://angularjs.org/
[AngularUI Bootstrap]: https://angular-ui.github.io/bootstrap/
[font-awesome]: https://fortawesome.github.io/Font-Awesome/
[flag-icon-css]: https://lipis.github.io/flag-icon-css/
* `npm install && npm install -g gulp` to install the environment`
* gulp build` build the component, the docs and the demo`
* gulp serve` serve the demo`
* gulp test`` test the component with karama
MIT License (MIT)
Copyright (c) 2015 Avi Sharvit