Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add language setting to Project Settings #1589

Merged
merged 6 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions novelwriter/assets/i18n/project_nn_NO.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@
"Synopsis": "Samandrag",
"Comment": "Kommentar",
"Notes": "Notat",
"Tag": "Knagg",
"Point of View": "Perspektiv",
"Focus": "Fokus",
"Characters": "Karakterar",
"Plot": "Plott",
"Timeline": "Tidslinje",
"Locations": "Lokasjonar",
"Objects": "Objekt",
"Entities": "Eining",
"Custom": "Anna",
"0": "null",
"1": "ein",
"2": "to",
Expand Down
2 changes: 0 additions & 2 deletions novelwriter/core/buildsettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
"text.includeKeywords": (bool, False),
"text.includeBodyText": (bool, True),
"text.addNoteHeadings": (bool, True),
"format.buildLang": (str, "en_GB"),
"format.textFont": (str, CONFIG.textFont),
"format.textSize": (int, 12),
"format.lineHeight": (float, 1.15, 0.75, 3.0),
Expand Down Expand Up @@ -107,7 +106,6 @@
"text.addNoteHeadings": QT_TRANSLATE_NOOP("Builds", "Add Titles for Notes"),

"format.grpFormat": QT_TRANSLATE_NOOP("Builds", "Text Format"),
"format.buildLang": QT_TRANSLATE_NOOP("Builds", "Language"),
"format.textFont": QT_TRANSLATE_NOOP("Builds", "Font Family"),
"format.textSize": QT_TRANSLATE_NOOP("Builds", "Font Size"),
"format.lineHeight": QT_TRANSLATE_NOOP("Builds", "Line Height"),
Expand Down
2 changes: 2 additions & 0 deletions novelwriter/core/coretools.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,11 +353,13 @@ def buildProject(self, data: dict) -> bool:
projName = data.get("projName", lblNewProject)
projTitle = data.get("projTitle", lblNewProject)
projAuthor = data.get("projAuthor", "")
projLang = data.get("projLang", "en_GB")

project.data.setUuid(None)
project.data.setName(projName)
project.data.setTitle(projTitle)
project.data.setAuthor(projAuthor)
project.data.setLanguage(projLang)
project.setDefaultStatusImport()
project.session.startSession()

Expand Down
6 changes: 1 addition & 5 deletions novelwriter/core/docbuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,13 +248,9 @@ def iterBuildNWD(self, path: Path | None, asJson: bool = False) -> Iterable[tupl
def _setupBuild(self, bldObj: Tokenizer) -> dict:
"""Configure the build object."""
# Get Settings
buildLang = self._build.getStr("format.buildLang")
textFont = self._build.getStr("format.textFont")
textSize = self._build.getInt("format.textSize")

# The language lookup dict is reloaded if needed
self._project.setProjectLang(buildLang)

fontFamily = textFont or CONFIG.textFont
bldFont = QFont(fontFamily, textSize)
fontInfo = QFontInfo(bldFont)
Expand Down Expand Up @@ -287,7 +283,7 @@ def _setupBuild(self, bldObj: Tokenizer) -> dict:

if isinstance(bldObj, ToOdt):
bldObj.setColourHeaders(self._build.getBool("odt.addColours"))
bldObj.setLanguage(buildLang)
bldObj.setLanguage(self._project.data.language)

scale = nwLabels.UNIT_SCALE.get(self._build.getStr("format.pageUnit"), 1.0)
pW, pH = nwLabels.PAPER_SIZE.get(self._build.getStr("format.pageSize"), (-1.0, -1.0))
Expand Down
4 changes: 2 additions & 2 deletions novelwriter/core/projectdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,14 @@ def initCounts(self) -> tuple[int, int]:
"""Return the initial count of words for novel and note
documents.
"""
return tuple(self._initCounts)
return self._initCounts[0], self._initCounts[1]

@property
def currCounts(self) -> tuple[int, int]:
"""Return the current count of words for novel and note
documents.
"""
return tuple(self._currCounts)
return self._currCounts[0], self._currCounts[1]

@property
def lastHandle(self) -> dict[str, str | None]:
Expand Down
3 changes: 1 addition & 2 deletions novelwriter/core/tohtml.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,11 +456,10 @@ def getStyleSheet(self) -> list[str]:

def _formatSynopsis(self, text: str) -> str:
"""Apply HTML formatting to synopsis."""
sSynop = self._localLookup("Synopsis")
if self._genMode == self.M_PREVIEW:
sSynop = self._trSynopsis
return f"<p class='comment'><span class='synopsis'>{sSynop}:</span> {text}</p>\n"
else:
sSynop = self._localLookup("Synopsis")
return f"<p class='synopsis'><strong>{sSynop}:</strong> {text}</p>\n"

def _formatComments(self, text: str) -> str:
Expand Down
3 changes: 0 additions & 3 deletions novelwriter/core/tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,6 @@ def __init__(self, project: NWProject) -> None:
self._localLookup = self._project.localLookup
self.tr = partial(QCoreApplication.translate, "Tokenizer")

# Cached Translations
self._trSynopsis = self.tr("Synopsis")

# Format RegEx
self._rxMarkdown = [
(QRegularExpression(nwRegEx.FMT_EI), [0, self.FMT_I_B, 0, self.FMT_I_E]),
Expand Down
Loading