Use Qt for int locale
This commit is contained in:
@@ -469,6 +469,10 @@ class Config:
|
||||
"""Return a localised datetime format."""
|
||||
return self._dLocale.toString(value, self._dShortDateTime)
|
||||
|
||||
def localInt(self, value: int) -> str:
|
||||
"""Return a localised integer."""
|
||||
return self._dLocale.toString(value)
|
||||
|
||||
def listLanguages(self, lngSet: int) -> list[tuple[str, str]]:
|
||||
"""List localisation files in the i18n folder. The default GUI
|
||||
language is British English (en_GB).
|
||||
|
||||
@@ -36,7 +36,7 @@ from zipfile import ZIP_DEFLATED, ZipFile
|
||||
from PyQt5.QtCore import QMarginsF, QSizeF
|
||||
from PyQt5.QtGui import QColor
|
||||
|
||||
from novelwriter import __version__
|
||||
from novelwriter import CONFIG, __version__
|
||||
from novelwriter.common import firstFloat, xmlSubElem
|
||||
from novelwriter.constants import nwHeadFmt, nwStyles
|
||||
from novelwriter.core.project import NWProject
|
||||
@@ -936,7 +936,7 @@ class ToDocX(Tokenizer):
|
||||
if self._usedFields and self._counts:
|
||||
for xField, field in self._usedFields:
|
||||
if (value := self._counts.get(field)) is not None:
|
||||
xField.text = f"{value:n}"
|
||||
xField.text = CONFIG.localInt(value)
|
||||
|
||||
# Write Paragraphs
|
||||
for par in pars:
|
||||
|
||||
@@ -29,6 +29,7 @@ import logging
|
||||
from pathlib import Path
|
||||
from time import time
|
||||
|
||||
from novelwriter import CONFIG
|
||||
from novelwriter.common import formatTimeStamp
|
||||
from novelwriter.constants import nwHtmlUnicode
|
||||
from novelwriter.core.project import NWProject
|
||||
@@ -257,7 +258,9 @@ class ToHtml(Tokenizer):
|
||||
pages = len(self._pages)
|
||||
for doc, field in self._usedFields:
|
||||
if doc >= 0 and doc < pages and (value := self._counts.get(field)) is not None:
|
||||
self._pages[doc] = self._pages[doc].replace(f"{{{{{field}}}}}", f"{value:n}")
|
||||
self._pages[doc] = self._pages[doc].replace(
|
||||
f"{{{{{field}}}}}", CONFIG.localInt(value)
|
||||
)
|
||||
|
||||
# Add footnotes
|
||||
if self._usedNotes:
|
||||
|
||||
@@ -27,6 +27,7 @@ import logging
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from novelwriter import CONFIG
|
||||
from novelwriter.constants import nwUnicode
|
||||
from novelwriter.core.project import NWProject
|
||||
from novelwriter.formats.shared import BlockFmt, BlockTyp, T_Formats, TextFmt
|
||||
@@ -157,7 +158,9 @@ class ToMarkdown(Tokenizer):
|
||||
pages = len(self._pages)
|
||||
for doc, field in self._usedFields:
|
||||
if doc >= 0 and doc < pages and (value := self._counts.get(field)) is not None:
|
||||
self._pages[doc] = self._pages[doc].replace(f"{{{{{field}}}}}", f"{value:n}")
|
||||
self._pages[doc] = self._pages[doc].replace(
|
||||
f"{{{{{field}}}}}", CONFIG.localInt(value)
|
||||
)
|
||||
|
||||
# Add footnotes
|
||||
if self._usedNotes:
|
||||
|
||||
@@ -34,6 +34,7 @@ from PyQt5.QtGui import (
|
||||
)
|
||||
from PyQt5.QtPrintSupport import QPrinter
|
||||
|
||||
from novelwriter import CONFIG
|
||||
from novelwriter.constants import nwStyles, nwUnicode
|
||||
from novelwriter.core.project import NWProject
|
||||
from novelwriter.formats.shared import BlockFmt, BlockTyp, T_Formats, TextFmt
|
||||
@@ -258,7 +259,7 @@ class ToQTextDocument(Tokenizer):
|
||||
if (value := self._counts.get(field)) is not None:
|
||||
cursor.setPosition(pos, QtMoveAnchor)
|
||||
cursor.setPosition(pos + 1, QtKeepAnchor)
|
||||
cursor.insertText(f"{value:n}")
|
||||
cursor.insertText(CONFIG.localInt(value))
|
||||
|
||||
# Add footnotes
|
||||
if self._usedNotes:
|
||||
|
||||
Reference in New Issue
Block a user