Skip to content

Commit

Permalink
Change context of shape translation strings (#2249)
Browse files Browse the repository at this point in the history
  • Loading branch information
vkbo authored Feb 16, 2025
2 parents 3ff4cc4 + c0bb0fa commit c5e0258
Show file tree
Hide file tree
Showing 20 changed files with 11,639 additions and 11,678 deletions.
535 changes: 266 additions & 269 deletions i18n/nw_base.ts

Large diffs are not rendered by default.

2,207 changes: 1,102 additions & 1,105 deletions i18n/nw_cs_CZ.ts

Large diffs are not rendered by default.

2,207 changes: 1,102 additions & 1,105 deletions i18n/nw_de_DE.ts

Large diffs are not rendered by default.

2,207 changes: 1,102 additions & 1,105 deletions i18n/nw_en_US.ts

Large diffs are not rendered by default.

2,207 changes: 1,102 additions & 1,105 deletions i18n/nw_es_419.ts

Large diffs are not rendered by default.

705 changes: 351 additions & 354 deletions i18n/nw_fr_FR.ts

Large diffs are not rendered by default.

2,211 changes: 1,104 additions & 1,107 deletions i18n/nw_it_IT.ts

Large diffs are not rendered by default.

2,207 changes: 1,102 additions & 1,105 deletions i18n/nw_ja_JP.ts

Large diffs are not rendered by default.

2,207 changes: 1,102 additions & 1,105 deletions i18n/nw_nb_NO.ts

Large diffs are not rendered by default.

705 changes: 351 additions & 354 deletions i18n/nw_nl_NL.ts

Large diffs are not rendered by default.

2,209 changes: 1,103 additions & 1,106 deletions i18n/nw_pl_PL.ts

Large diffs are not rendered by default.

2,207 changes: 1,102 additions & 1,105 deletions i18n/nw_pt_BR.ts

Large diffs are not rendered by default.

703 changes: 350 additions & 353 deletions i18n/nw_ru_RU.ts

Large diffs are not rendered by default.

703 changes: 350 additions & 353 deletions i18n/nw_zh_CN.ts

Large diffs are not rendered by default.

51 changes: 27 additions & 24 deletions novelwriter/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,21 @@
"""
from __future__ import annotations

from typing import Literal

from PyQt5.QtCore import QT_TRANSLATE_NOOP, QCoreApplication

from novelwriter.enum import (
nwBuildFmt, nwComment, nwItemClass, nwItemLayout, nwOutline, nwStatusShape
)


def trConst(text: str, context: Literal["Constant", "Stats", "Shape"] = "Constant") -> str:
def trConst(text: str) -> str:
"""Wrapper function for locally translating constants."""
return QCoreApplication.translate(context, text)
return QCoreApplication.translate("Constant", text)


def trStats(text: str) -> str:
"""Wrapper function for locally translating stats constants."""
return QCoreApplication.translate("Stats", text)


class nwConst:
Expand Down Expand Up @@ -372,32 +375,32 @@ class nwLabels:
nwBuildFmt.J_NWD: ".json",
}
SHAPES_PLAIN = {
nwStatusShape.SQUARE: QT_TRANSLATE_NOOP("Shape", "Square"),
nwStatusShape.TRIANGLE: QT_TRANSLATE_NOOP("Shape", "Triangle"),
nwStatusShape.NABLA: QT_TRANSLATE_NOOP("Shape", "Nabla"),
nwStatusShape.DIAMOND: QT_TRANSLATE_NOOP("Shape", "Diamond"),
nwStatusShape.PENTAGON: QT_TRANSLATE_NOOP("Shape", "Pentagon"),
nwStatusShape.HEXAGON: QT_TRANSLATE_NOOP("Shape", "Hexagon"),
nwStatusShape.STAR: QT_TRANSLATE_NOOP("Shape", "Star"),
nwStatusShape.PACMAN: QT_TRANSLATE_NOOP("Shape", "Pacman"),
nwStatusShape.SQUARE: QT_TRANSLATE_NOOP("Constant", "Square"),
nwStatusShape.TRIANGLE: QT_TRANSLATE_NOOP("Constant", "Triangle"),
nwStatusShape.NABLA: QT_TRANSLATE_NOOP("Constant", "Nabla"),
nwStatusShape.DIAMOND: QT_TRANSLATE_NOOP("Constant", "Diamond"),
nwStatusShape.PENTAGON: QT_TRANSLATE_NOOP("Constant", "Pentagon"),
nwStatusShape.HEXAGON: QT_TRANSLATE_NOOP("Constant", "Hexagon"),
nwStatusShape.STAR: QT_TRANSLATE_NOOP("Constant", "Star"),
nwStatusShape.PACMAN: QT_TRANSLATE_NOOP("Constant", "Pacman"),
}
SHAPES_CIRCLE = {
nwStatusShape.CIRCLE_Q: QT_TRANSLATE_NOOP("Shape", "1/4 Circle"),
nwStatusShape.CIRCLE_H: QT_TRANSLATE_NOOP("Shape", "Half Circle"),
nwStatusShape.CIRCLE_T: QT_TRANSLATE_NOOP("Shape", "3/4 Circle"),
nwStatusShape.CIRCLE: QT_TRANSLATE_NOOP("Shape", "Full Circle"),
nwStatusShape.CIRCLE_Q: QT_TRANSLATE_NOOP("Constant", "1/4 Circle"),
nwStatusShape.CIRCLE_H: QT_TRANSLATE_NOOP("Constant", "Half Circle"),
nwStatusShape.CIRCLE_T: QT_TRANSLATE_NOOP("Constant", "3/4 Circle"),
nwStatusShape.CIRCLE: QT_TRANSLATE_NOOP("Constant", "Full Circle"),
}
SHAPES_BARS = {
nwStatusShape.BARS_1: QT_TRANSLATE_NOOP("Shape", "1 Bar"),
nwStatusShape.BARS_2: QT_TRANSLATE_NOOP("Shape", "2 Bars"),
nwStatusShape.BARS_3: QT_TRANSLATE_NOOP("Shape", "3 Bars"),
nwStatusShape.BARS_4: QT_TRANSLATE_NOOP("Shape", "4 Bars"),
nwStatusShape.BARS_1: QT_TRANSLATE_NOOP("Constant", "1 Bar"),
nwStatusShape.BARS_2: QT_TRANSLATE_NOOP("Constant", "2 Bars"),
nwStatusShape.BARS_3: QT_TRANSLATE_NOOP("Constant", "3 Bars"),
nwStatusShape.BARS_4: QT_TRANSLATE_NOOP("Constant", "4 Bars"),
}
SHAPES_BLOCKS = {
nwStatusShape.BLOCK_1: QT_TRANSLATE_NOOP("Shape", "1 Block"),
nwStatusShape.BLOCK_2: QT_TRANSLATE_NOOP("Shape", "2 Blocks"),
nwStatusShape.BLOCK_3: QT_TRANSLATE_NOOP("Shape", "3 Blocks"),
nwStatusShape.BLOCK_4: QT_TRANSLATE_NOOP("Shape", "4 Blocks"),
nwStatusShape.BLOCK_1: QT_TRANSLATE_NOOP("Constant", "1 Block"),
nwStatusShape.BLOCK_2: QT_TRANSLATE_NOOP("Constant", "2 Blocks"),
nwStatusShape.BLOCK_3: QT_TRANSLATE_NOOP("Constant", "3 Blocks"),
nwStatusShape.BLOCK_4: QT_TRANSLATE_NOOP("Constant", "4 Blocks"),
}
FILE_FILTERS = {
"*.txt": QT_TRANSLATE_NOOP("Constant", "Text files"),
Expand Down
2 changes: 1 addition & 1 deletion novelwriter/dialogs/projectsettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ def __init__(self, parent: QWidget, isStatus: bool) -> None:
def buildMenu(menu: QMenu, items: dict[nwStatusShape, str]) -> None:
for shape, label in items.items():
icon = NWStatus.createIcon(self._iPx, iColor, shape)
action = menu.addAction(icon, trConst(label, "Shape"))
action = menu.addAction(icon, trConst(label))
action.triggered.connect(qtLambda(self._selectShape, shape))
self._icons[shape] = icon

Expand Down
8 changes: 4 additions & 4 deletions novelwriter/gui/itemdetails.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

from novelwriter import CONFIG, SHARED
from novelwriter.common import elide
from novelwriter.constants import nwLabels, nwStats, trConst
from novelwriter.constants import nwLabels, nwStats, trConst, trStats
from novelwriter.enum import nwChange
from novelwriter.types import (
QtAlignLeft, QtAlignLeftBase, QtAlignRight, QtAlignRightBase,
Expand Down Expand Up @@ -65,9 +65,9 @@ def __init__(self, parent: QWidget) -> None:
fntValue = self.font()
fntValue.setPointSizeF(0.9*fPt)

trStats1 = trConst(nwLabels.STATS_NAME[nwStats.CHARS], "Stats")
trStats2 = trConst(nwLabels.STATS_NAME[nwStats.WORDS], "Stats")
trStats3 = trConst(nwLabels.STATS_NAME[nwStats.PARAGRAPHS], "Stats")
trStats1 = trStats(nwLabels.STATS_NAME[nwStats.CHARS])
trStats2 = trStats(nwLabels.STATS_NAME[nwStats.WORDS])
trStats3 = trStats(nwLabels.STATS_NAME[nwStats.PARAGRAPHS])

# Label
self.labelName = QLabel(self.tr("Label"), self)
Expand Down
4 changes: 2 additions & 2 deletions novelwriter/gui/mainmenu.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
from novelwriter.common import openExternalPath, qtLambda
from novelwriter.constants import (
nwConst, nwKeyWords, nwLabels, nwShortcode, nwStats, nwStyles, nwUnicode,
trConst
trConst, trStats
)
from novelwriter.enum import nwDocAction, nwDocInsert, nwFocus, nwView
from novelwriter.extensions.eventfilters import StatusTipFilter
Expand Down Expand Up @@ -601,7 +601,7 @@ def _buildInsertMenu(self) -> None:
self.mInsField = self.insMenu.addMenu(self.tr("Word/Character Count"))
for field in nwStats.ALL_FIELDS:
value = nwShortcode.FIELD_VALUE.format(field)
action = self.mInsField.addAction(trConst(nwLabels.STATS_NAME[field], "Stats"))
action = self.mInsField.addAction(trStats(nwLabels.STATS_NAME[field]))
action.triggered.connect(qtLambda(self.requestDocInsertText.emit, value))

# Insert > Breaks and Vertical Space
Expand Down
8 changes: 4 additions & 4 deletions novelwriter/gui/outline.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

from novelwriter import CONFIG, SHARED
from novelwriter.common import checkInt, formatFileFilter
from novelwriter.constants import nwKeyWords, nwLabels, nwStats, nwStyles, trConst
from novelwriter.constants import nwKeyWords, nwLabels, nwStats, nwStyles, trConst, trStats
from novelwriter.enum import nwChange, nwDocMode, nwItemClass, nwItemLayout, nwItemType, nwOutline
from novelwriter.error import logException
from novelwriter.extensions.configlayout import NColourLabel
Expand Down Expand Up @@ -815,9 +815,9 @@ def __init__(self, outlineView: GuiOutlineView) -> None:

bFont = SHARED.theme.guiFontB

trStats1 = trConst(nwLabels.STATS_NAME[nwStats.CHARS], "Stats")
trStats2 = trConst(nwLabels.STATS_NAME[nwStats.WORDS], "Stats")
trStats3 = trConst(nwLabels.STATS_NAME[nwStats.PARAGRAPHS], "Stats")
trStats1 = trStats(nwLabels.STATS_NAME[nwStats.CHARS])
trStats2 = trStats(nwLabels.STATS_NAME[nwStats.WORDS])
trStats3 = trStats(nwLabels.STATS_NAME[nwStats.PARAGRAPHS])

# Details Area
self.titleLabel = QLabel(self.tr("Title"), self)
Expand Down
24 changes: 12 additions & 12 deletions novelwriter/tools/manuscript.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

from novelwriter import CONFIG, SHARED
from novelwriter.common import fuzzyTime
from novelwriter.constants import nwLabels, nwStats, trConst
from novelwriter.constants import nwLabels, nwStats, trStats
from novelwriter.core.buildsettings import BuildCollection, BuildSettings
from novelwriter.core.docbuild import NWBuildDocument
from novelwriter.extensions.modified import NIconToggleButton, NIconToolButton, NToolDialog
Expand Down Expand Up @@ -1037,17 +1037,17 @@ def _buildBottomPanel(self) -> None:
hPx = CONFIG.pxInt(12)
vPx = CONFIG.pxInt(4)

trAllChars = trConst(nwLabels.STATS_NAME[nwStats.CHARS], "Stats")
trTextChars = trConst(nwLabels.STATS_NAME[nwStats.CHARS_TEXT], "Stats")
trTitleChars = trConst(nwLabels.STATS_NAME[nwStats.CHARS_TITLE], "Stats")
trParagraphCount = trConst(nwLabels.STATS_NAME[nwStats.PARAGRAPHS], "Stats")
trTitleCount = trConst(nwLabels.STATS_NAME[nwStats.TITLES], "Stats")
trAllWordChars = trConst(nwLabels.STATS_NAME[nwStats.WCHARS_ALL], "Stats")
trTextWordChars = trConst(nwLabels.STATS_NAME[nwStats.WCHARS_TEXT], "Stats")
trTitleWordChars = trConst(nwLabels.STATS_NAME[nwStats.WCHARS_TITLE], "Stats")
trAllWords = trConst(nwLabels.STATS_NAME[nwStats.WORDS], "Stats")
trTextWords = trConst(nwLabels.STATS_NAME[nwStats.WORDS_TEXT], "Stats")
trTitleWords = trConst(nwLabels.STATS_NAME[nwStats.WORDS_TITLE], "Stats")
trAllChars = trStats(nwLabels.STATS_NAME[nwStats.CHARS])
trTextChars = trStats(nwLabels.STATS_NAME[nwStats.CHARS_TEXT])
trTitleChars = trStats(nwLabels.STATS_NAME[nwStats.CHARS_TITLE])
trParagraphCount = trStats(nwLabels.STATS_NAME[nwStats.PARAGRAPHS])
trTitleCount = trStats(nwLabels.STATS_NAME[nwStats.TITLES])
trAllWordChars = trStats(nwLabels.STATS_NAME[nwStats.WCHARS_ALL])
trTextWordChars = trStats(nwLabels.STATS_NAME[nwStats.WCHARS_TEXT])
trTitleWordChars = trStats(nwLabels.STATS_NAME[nwStats.WCHARS_TITLE])
trAllWords = trStats(nwLabels.STATS_NAME[nwStats.WORDS])
trTextWords = trStats(nwLabels.STATS_NAME[nwStats.WORDS_TEXT])
trTitleWords = trStats(nwLabels.STATS_NAME[nwStats.WORDS_TITLE])

# Minimal Form
self.minWordCount = QLabel(self)
Expand Down

0 comments on commit c5e0258

Please sign in to comment.