fix translation installation

I really don't get why, but it only works if I do it this way.
I thought that `translation.install` should make _() able to
fetch messages from anywhere in the program, but nothing was
translated in my tests except _() calls in inkstitch.py.
pull/56/merge
Lex Neva 2018-02-04 15:59:20 -05:00
rodzic bd0e1eef81
commit 8ec65c1352
4 zmienionych plików z 10 dodań i 12 usunięć

Wyświetl plik

@ -35,9 +35,7 @@ import networkx
from pprint import pformat
import inkstitch
from inkstitch import cache, dbg, param, EmbroideryElement, get_nodes, SVG_POLYLINE_TAG, SVG_GROUP_TAG, PIXELS_PER_MM, get_viewbox_transform
inkstitch.localize()
from inkstitch import _, cache, dbg, param, EmbroideryElement, get_nodes, SVG_POLYLINE_TAG, SVG_GROUP_TAG, PIXELS_PER_MM, get_viewbox_transform
class Fill(EmbroideryElement):
def __init__(self, *args, **kwargs):

Wyświetl plik

@ -14,16 +14,13 @@ from wx.lib.scrolledpanel import ScrolledPanel
from collections import defaultdict
import inkex
import inkstitch
from inkstitch import Param, EmbroideryElement, get_nodes
from inkstitch import _, Param, EmbroideryElement, get_nodes
from embroider import Fill, AutoFill, Stroke, SatinColumn
from functools import partial
from itertools import groupby
from embroider_simulate import EmbroiderySimulator
inkstitch.localize()
def presets_path():
try:
import appdirs

Wyświetl plik

@ -8,10 +8,7 @@ import colorsys
import inkstitch
from inkstitch import PIXELS_PER_MM
from embroider import patches_to_stitches, get_elements, elements_to_patches
inkstitch.localize()
from embroider import _, patches_to_stitches, get_elements, elements_to_patches
class EmbroiderySimulator(wx.Frame):

Wyświetl plik

@ -33,6 +33,8 @@ EMBROIDERABLE_TAGS = (SVG_PATH_TAG, SVG_POLYLINE_TAG)
dbg = open("/tmp/embroider-debug.txt", "w")
_ = lambda message: message
# simplify use of lru_cache decorator
def cache(*args, **kwargs):
return lru_cache(maxsize=None)(*args, **kwargs)
@ -47,7 +49,11 @@ def localize():
locale_dir = os.path.join(locale_dir, 'locales')
translation = gettext.translation("inkstitch", locale_dir, fallback=True)
translation.install()
global _
_ = translation.gettext
localize()
# cribbed from inkscape-silhouette
def parse_length_with_units( str ):