https://github.com/rbatinov/multilanguagewebsitejs
This is a template for MultiLanguage support of a website. It uses only JavaScript to implement the logic. It is easy to implement and does not require some extra frameworks or extensions.
https://github.com/rbatinov/multilanguagewebsitejs
javascript multilanguage multilanguage-support simple translate translation translators web webapp webapplication website
Last synced: 8 months ago
JSON representation
This is a template for MultiLanguage support of a website. It uses only JavaScript to implement the logic. It is easy to implement and does not require some extra frameworks or extensions.
- Host: GitHub
- URL: https://github.com/rbatinov/multilanguagewebsitejs
- Owner: rbatinov
- Created: 2020-09-22T14:58:26.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2021-07-10T10:51:13.000Z (almost 5 years ago)
- Last Synced: 2025-01-06T00:44:08.793Z (over 1 year ago)
- Topics: javascript, multilanguage, multilanguage-support, simple, translate, translation, translators, web, webapp, webapplication, website
- Language: HTML
- Homepage: https://rbatinov.github.io/MultiLanguageWebsiteJS/
- Size: 66.4 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# MultiLanguage Website with JavaScript
This is a template for MultiLanguage support of a website.
It uses only JavaScript to implement the logic.
It is easy to implement and does not require some extra frameworks or extensions.
You can check here the [DEMO](https://rbatinov.github.io/MultiLanguageWebsiteJS/)
Structure of Project:
- Resources Folder
- Here you can store all files with translations - in this example these are en.js and bg.js.
- You simply create a variable with keys and string value with translation.
- Key values need to be added in data-tag attribute in every HTML element which you want to be translated.
- Scripts Folder
- defaultValues.js
- All default values for the template.
- myFunctions.js
- All functions that are used.
- getCookie - it is used to check if cookie with language exists. I prefer to store the language in cookie in order to remember the clients preferences.
- translateAll - translates all elements in DOM where data-tag exists
- Note that all html elements need to have data-tag attribute with their key in order to be translated.
- Translate.js
- This is the implementation of the Language class. It creates an instance with default language. The default language is set in the defaltValues.js file.
- getVal - returns the translated value by the key passed. You can pass default value, if no key exists or 'undefined' will be returend.
- Styles Folder
- style.css - simple styles for presentation page
- index.html
- Example page where you can test the translation of page.
## Enjoy!