View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update | 
|---|---|---|---|---|---|
| 0015584 | Scribus | Language Tools | public | 2019-03-01 00:02 | 2019-03-01 17:13 | 
| Reporter | william | Assigned To | |||
| Priority | normal | Severity | minor | Reproducibility | always | 
| Status | new | Resolution | open | ||
| Product Version | 1.5.5.svn | ||||
| Summary | 0015584: [patch] Warn when a hyphenation dictionary is missing | ||||
| Description | I had two documents, both in English, and Scribus was hyphenating one but not the other. I put in debug code, and apparently one document was British English and the other was US English. Scribus found the British English hyphenation dictionary hyph_en_GB.dic in its resources, but it didn't have a corresponding US English hyphenation dictionary. I have Fedora 28 x86_64 Linux, and I installed the 'hyphen-en' package, which created /usr/share/hyphen/hyph_en_US.dic, and then Scribus found it and hyphenated my document. The Fedora/RedHat/CentOS notes for Scribus should probably mention installing the hyphen-en package. The hyphen-en package creates a lot of symbolic links in /usr/share/hyphen that all point to hyph_en_US.dic, so maybe Scribus can use its en_GB dictionary for other English regions as well. I have attached a patch to hyphenator.cpp that shows a warning on the first attempt to reference a missing hyphenation dictionary. Probably LanguageManager should have a flag for languages that are ok without hyphenation dictionaries so this warning does not get annoying. I have Scribus 1.5.5.svn that I built from source. The product version pull down in mantis only goes up to 1.5.4.svn. | ||||
| Tags | No tags attached. | ||||
| Attached Files |  scribus-hyphenator-warning-20190228-233546.pat (1,467 bytes)   
 *** scribus/hyphenator.cpp	2019-02-28 05:09:51.937524116 +0000
--- /var/tmp/scribus15/scribus/hyphenator.cpp	2019-02-28 23:28:35.344995014 +0000
*************** Hyphenator::~Hyphenator()
*** 58,65 ****
  
  bool Hyphenator::loadDict(const QString& name)
  {
! 	if (LanguageManager::instance()->getHyphFilename(name).isEmpty())
  		return false;
  		
  	if (m_language != name)
  	{
--- 58,73 ----
  
  bool Hyphenator::loadDict(const QString& name)
  {
! 	static QStringList didWarning;
! 	if (LanguageManager::instance()->getHyphFilename(name).isEmpty()) {
! 		if (!didWarning.contains(name)) {
! 			didWarning.append(name);
! 			QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor));
! 			ScMessageBox::warning(nullptr, CommonStrings::trWarning, tr("Hyphenation is not available for language '%1'.").arg(name));
! 			QApplication::restoreOverrideCursor();
! 		}
  		return false;
+ 	}
  		
  	if (m_language != name)
  	{
*************** bool Hyphenator::loadDict(const QString&
*** 78,83 ****
--- 86,99 ----
  			return true;
  		}
  		m_hdict = nullptr;
+ 		if (!didWarning.contains(name)) {
+ 			didWarning.append(name);
+ 			QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor));
+ 			ScMessageBox::warning(nullptr, CommonStrings::trWarning,
+ 				tr("Hyphenation file '%1' for language '%2' not found.")
+ 					.arg(LanguageManager::instance()->getHyphFilename(name), name));
+ 			QApplication::restoreOverrideCursor();
+ 		}
  		return false;
  	}
  
 | ||||
| Patch | Yes | ||||
|  | a/ i've updated the version... 1.5.5svn is available : - ) b/ i upload a diff so that the patch can be seen by expanding it in mantis c/ i like the idea of warning the user when the hyphenation does not happen because of a missing dictionary... the patch is very simple, but i don't really like that a pop is shown the first time it's used. d/ i wonder if this should not go into the preflight verifier... e/ ... and/or below the language select box in the PP what do you think?  scribus-hyphenator-warning-20190228-233546.diff (1,467 bytes)   
 *** scribus/hyphenator.cpp	2019-02-28 05:09:51.937524116 +0000
--- /var/tmp/scribus15/scribus/hyphenator.cpp	2019-02-28 23:28:35.344995014 +0000
*************** Hyphenator::~Hyphenator()
*** 58,65 ****
  
  bool Hyphenator::loadDict(const QString& name)
  {
! 	if (LanguageManager::instance()->getHyphFilename(name).isEmpty())
  		return false;
  		
  	if (m_language != name)
  	{
--- 58,73 ----
  
  bool Hyphenator::loadDict(const QString& name)
  {
! 	static QStringList didWarning;
! 	if (LanguageManager::instance()->getHyphFilename(name).isEmpty()) {
! 		if (!didWarning.contains(name)) {
! 			didWarning.append(name);
! 			QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor));
! 			ScMessageBox::warning(nullptr, CommonStrings::trWarning, tr("Hyphenation is not available for language '%1'.").arg(name));
! 			QApplication::restoreOverrideCursor();
! 		}
  		return false;
+ 	}
  		
  	if (m_language != name)
  	{
*************** bool Hyphenator::loadDict(const QString&
*** 78,83 ****
--- 86,99 ----
  			return true;
  		}
  		m_hdict = nullptr;
+ 		if (!didWarning.contains(name)) {
+ 			didWarning.append(name);
+ 			QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor));
+ 			ScMessageBox::warning(nullptr, CommonStrings::trWarning,
+ 				tr("Hyphenation file '%1' for language '%2' not found.")
+ 					.arg(LanguageManager::instance()->getHyphFilename(name), name));
+ 			QApplication::restoreOverrideCursor();
+ 		}
  		return false;
  	}
  
 | 
|  | Thanks. I think that the language selection box is better than the preflight verifier because if you are trying to figure out why a document isn't hyphenating, you might think to double-check the language, but you might not try the preflight verifier until immediately before trying to produce a PDF. Also, each page can have multiple text frames; each text frame can have text with multiple styles; each style can have a different language, so the preflight verifier could potentially show a large number of warnings. | 
|  | it's possible that both are needed. (as an example for the case that you get a file from somebody who had the hyphenation, you edit and then produce a pdf) for the number of warnings: - you're right - you can turn off warnings in the settings - i think that if you pick a language you should have its hyphenation installed - (what to do for languages that do not have (yet) an hyphenation?) | 
| Date Modified | Username | Field | Change | 
|---|---|---|---|
| 2019-03-01 00:02 | william | New Issue | |
| 2019-03-01 00:02 | william | File Added: scribus-hyphenator-warning-20190228-233546.pat | |
| 2019-03-01 08:29 | ale | Product Version | 1.5.4.svn => 1.5.5.svn | 
| 2019-03-01 08:29 | ale | Description Updated | |
| 2019-03-01 08:32 | ale | File Added: scribus-hyphenator-warning-20190228-233546.diff | |
| 2019-03-01 08:32 | ale | Note Added: 0045941 | |
| 2019-03-01 15:22 | william | Note Added: 0045943 | |
| 2019-03-01 17:13 | ale | Note Added: 0045944 | 
