I'm having trouble implementing Hyphenopoly (https://github.com/mnater/Hyphenopoly) on a Django project. Sometimes it seems to work fine, sometimes not. Besides, on mobile browser the result are unpleasant, since hyphens appears in a pretty inconsistent fashion (or doesn't at all) on elements with italian language. Further, I cannot understand the documentation provided. My fault.
Herein I report part of the directory structure of the project
As you can see, and for what I understood, I loaded only few files from the original library, in order to hyphenate italian and english pieces of text (separated or mixed). The main language is still en, since I defined it in the lang attribute of the html element; for each element featuring italian content, I specified the language attribute accordingly (for mixed content, I used spans).
In the head element of my base.html:
<script src="{% static './hyphens/Hyphenopoly_Loader.js' %}"></script>
<script src="{% static 'HyphenConfig.js' %}"></script>
The HyphenConfig.js file, instead:
$(document).ready(function() {
var Hyphenopoly = {
require: {
'en-us': 'ALL',
'en': 'ALL',
'it': 'ALL'
},
paths: {
patterndir: "./hyphens/patterns/",
maindir: "./hyphens/"
},
setup: {
selectors: {
'.hyphenate': {
compound: "all",
leftmin: 0,
rightmin: 0,
minWordLength: 4
}
}
}
};
});
I also defined the hyphenate class in the global css file:
.hyphenate {
hyphens: auto !important;
-webkit-hyphens: auto !important;
-ms-hyphens: auto !important;
}
What I expected?
For each element, provided a language (en or it) and the hyphenate class, I expected a better result than what I observed.
Is it the implementation correct, or do I miss any file or configuration?
I'm the author of hyphenopoly.js There are some issues with your implementation.
Try the following (not tested):
Hyphenopoly.config({
require: {
'en-us': 'supercalifragilisticexpialidocious',
'it': 'architettonicamente'
},
fallbacks: {
'en': 'en-us'
},
paths: {
patterndir: "./hyphens/patterns/",
maindir: "./hyphens/"
},
setup: {
selectors: {
'.hyphenate': {
compound: "all",
minWordLength: 4
}
}
}
});