Comments (7)
So I haven't added support for translations at the moment (and I really don't have a good excuse for not doing so). There's a tiny amount of text that would requires translation (in a quick tally I found approx 40 all of which are short).
I think setting the language should be an option against the namespace ContentTools.LANGUAGE = 'en'
and as you say allowing a languages.json
file to be defined/loaded with additional translations.
I've marked this as an enhancement and will add it to the mile stone in the readme.
from contenttools.
@anthonyjb I can help with russian translation.
from contenttools.
@MalyshevDmitry thank you!
from contenttools.
I'm trying to write my own integration of translation, but I must face the fact, that every UI component was already created before the translation was loaded. For example the labels of tools can't be set properly, and fallback to default label text is applied. Is there any way to wait for the moment when translation is ready and defer elements creation?
I have tried to use some constructions with events and/or setInterval function, but without success.
namespace.coffee:
# Default language url - tvaliasek
LANGUAGE_URL: '/assets/content-tools/lang/en_US.json'
STRINGS: null
LANG_LOADING: false
# ...
# loading function for language file. Based on https://coffeescript-cookbook.github.io/chapters/ajax/ajax_request_without_jquery - tvaliasek
setLangUrl: (url) ->
ContentTools.LANGUAGE_URL = url
ContentTools.LANG_LOADING = true
req = new XMLHttpRequest()
req.addEventListener 'readystatechange', ->
if req.readyState is 4
successResultCodes = [200, 304]
if req.status in successResultCodes
data = eval '(' + req.responseText + ')'
console.log 'Loaded language file: ', data.langName
ContentTools.STRINGS = data;
else
console.error 'Error loading language file.'
ContentTools.LANG_LOADING = false
req.open 'GET', url, false
req.send()
# ...
tools.coffee:
# ...
# Common tools
class ContentTools.Tools.Bold extends ContentTools.Tool
# Make the current selection of text (non)bold (e.g <b>foo</b>).
ContentTools.ToolShelf.stow(@, 'bold')
@label = if ContentTools.STRINGS is null then 'Bold' else ContentTools.STRINGS.tools.labels.bold
@icon = 'bold'
# ...
init of editor:
ContentTools.setLangUrl('/js/content-tools/lang/cs_CZ.json');
ContentTools.StylePalette.add([
new ContentTools.Style('Warning', 'alert alert-warning', ['p','div']),
new ContentTools.Style('Button', 'btn btn-primary', ['a'])
]);
var editor = ContentTools.EditorApp.get();
editor.init('*[data-editable]', 'data-name');
cs_CZ.json:
{
"langName": "Česky - cs_CZ",
"tools": {
"labels":{
"bold": "Tučně",
"italic": "Kurzívou",
"link": "Vložit odkaz"
}
}
}
from contenttools.
@tvaliasek my plan for tomorrow and over the weekend is to look into adding support for multiple languages. I have an approach that I've used on other libraries I've worked on so I don't think it will take me too long to put something together (and I have volunteers for French and Russian so far and hopefully others will help translate more languages too).
The only nasty bit right now I can think of is translating the helper titles in ContentEdit, as the content is currently part of the CSS - so I'll have to change that.
Once my solution is in the dev branch I'll let you know and get you to review.
from contenttools.
Ok, I was just curious how it works. Sign me as volunteer for Czech translation.
from contenttools.
Basic multilingual support is now available - I've posted a short tutorial on how to use it. Right now though we're a tad short on languages (Pig Latin is the only one available right now - which is of no use other than to test the concept).
Guide available here: http://getcontenttools.com/tutorials/multilingual-support
from contenttools.
Related Issues (20)
- Problems extracting DOM to submit HOT 2
- Save issue - saves fine, but won't allow a second "save" HOT 5
- Making CT compatible with CSP style-src set to 'self'
- Can't edit files that were included or read by php HOT 17
- Edit multiple paragraphs at once. HOT 2
- Is there a way to change the default tag output for normal html tags HOT 2
- Missing translation in /src/scripts/ui/dialogs/table.coffee
- Problem update image classes HOT 5
- Build files to use dynamic import in pure javascript HOT 1
- How to use assign ? HOT 2
- Hot to keep style attributes on save.
- Support for Sass >= 1.33 HOT 11
- npm install failed HOT 2
- Feature: Support drag & drop of images
- The image uploader HOT 2
- Inspector bar doesn't show embedded HTML elements when wrapped with paragraph HOT 1
- Line breaks not saving
- Add class to a link
- Lazy loading of images
- Source code edit? Insert <script> tag HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from contenttools.