I use an ion-grid in my Ionic 3 app. The data to show, I receive as JSON object from my database. Some words don’t fit in the columns and are, hence, cut off and continued in the next row. No hyphen ("-") is added and the separation is without any context to grammar. Like this:
This looks really ugly. I would like to somehow add hyphenation. However, I don’t get it running.
I tried the css-way (as follows), but this didn’t have any effect
Thanks for the suggestion, @beck24. I tried word-break:break-word; before. This didn’t have any influence.
The word-break: break-all at least shows an effect: In a text, words are broken to new lines whenever the end of line is reached. However, no hyphen (“-”) is added and the separation is still done without any use of grammar.
// after imports declare hypher-variables
var Hypher = require('hypher');
var german = require('hyphenation.xx');
// xx stands for the language-pattern, e.g. "en-us". A full list can be found here: https://github.com/bramstein/hyphenation-patterns/tree/master/patterns
@Component({
selector: 'home-page',
templateUrl: 'home.html'
})
export class HomePage {
h = new Hypher(language);
constructor(...) { }
hyphenateWord(){
let hypenatedWord = this.h.hyphenateText("ThisIsAVeryLongWord);
}
}
An ideal solution would be to create an ionic attribute like text-hyphen similar to text-wrap. But I have no idea how and if it is possible to create own custom attributes like that.
Hi @CristianFlores. You don’t need to import anything. You just install the hypher-library as explained in the link I posted above. Then you can use it as I showed in the same post.