Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
1a4742c7
Commit
1a4742c7
authored
Aug 15, 2015
by
Weblate
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
c8f14bff
b9a10f9a
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
2 deletions
+31
-2
docs/changes.rst
docs/changes.rst
+1
-0
weblate/lang/models.py
weblate/lang/models.py
+7
-0
weblate/trans/models/dictionary.py
weblate/trans/models/dictionary.py
+15
-2
weblate/trans/models/unit.py
weblate/trans/models/unit.py
+8
-0
No files found.
docs/changes.rst
View file @
1a4742c7
...
...
@@ -24,6 +24,7 @@ Released on ? 2015.
* Support for adding new translations in XLIFF.
* Improved file format autodetection.
* Extended keyboard shortcuts.
* Improved dictionary matching for several languages.
weblate 2.3
-----------
...
...
weblate/lang/models.py
View file @
1a4742c7
...
...
@@ -483,3 +483,10 @@ class Language(models.Model, PercentMixin):
elif
self
.
code
==
'pt_BR'
:
self
.
nplurals
=
2
self
.
pluralequation
=
'n > 1'
def
base_code
(
self
):
return
self
.
code
.
replace
(
'_'
,
'-'
).
split
(
'-'
)[
0
]
def
uses_ngram
(
self
):
code
=
self
.
base_code
()
return
code
in
(
'ja'
,
'zh'
,
'ko'
)
weblate/trans/models/dictionary.py
View file @
1a4742c7
...
...
@@ -26,7 +26,10 @@ from weblate.trans.formats import AutoFormat, StringIOMode
from
weblate.trans.models.project
import
Project
from
translate.storage.csvl10n
import
csvfile
from
django.core.urlresolvers
import
reverse
from
whoosh.analysis
import
StandardAnalyzer
,
StemmingAnalyzer
from
whoosh.analysis
import
(
LanguageAnalyzer
,
StandardAnalyzer
,
StemmingAnalyzer
,
NgramAnalyzer
)
from
whoosh.lang
import
has_stemmer
class
DictionaryManager
(
models
.
Manager
):
...
...
@@ -133,7 +136,17 @@ class DictionaryManager(models.Manager):
# Prepare analyzers
# - standard analyzer simply splits words
# - stemming extracts stems, to catch things like plurals
analyzers
=
(
StandardAnalyzer
(),
StemmingAnalyzer
())
analyzers
=
[
StandardAnalyzer
(),
StemmingAnalyzer
(),
]
lang_code
=
unit
.
translation
.
language
.
base_code
()
# Add per language analyzer if Whoosh has it
if
has_stemmer
(
lang_code
):
analyzers
.
append
(
LanguageAnalyzer
(
lang_code
))
# Add ngram analyzer for languages like Chinese or Japanese
if
unit
.
translation
.
language
.
uses_ngram
():
analyzers
.
append
(
NGramAnalyzer
())
# Extract words from all plurals and from context
for
text
in
unit
.
get_source_plurals
()
+
[
unit
.
context
]:
...
...
weblate/trans/models/unit.py
View file @
1a4742c7
...
...
@@ -634,11 +634,19 @@ class Unit(models.Model):
translation__subproject
=
self
.
translation
.
subproject
,
context
=
self
.
context
,
)
if
not
same_source
.
exists
():
return
# Update source and contentsum
previous_source
=
same_source
[
0
].
source
same_source
.
update
(
source
=
self
.
target
,
contentsum
=
calculate_checksum
(
self
.
source
,
self
.
context
),
)
same_source
.
filter
(
translated
=
True
).
udpdate
(
translated
=
False
,
fuzzy
=
True
,
previous_source
=
previous_source
,
)
# Update source index, it's enough to do it for one as we index by
# checksum which is same for all
update_index_unit
(
self
,
True
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment