mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1147207 - Allow to give extra l10n directories to l10n-repack.py. r=gps
This allows to use separate l10n staging directories for e.g. addons.
This commit is contained in:
parent
cb47c355c4
commit
bd7aa25304
@ -19,7 +19,10 @@ from mozpack.packager import (
|
||||
SimplePackager,
|
||||
SimpleManifestSink,
|
||||
)
|
||||
from mozpack.files import ManifestFile
|
||||
from mozpack.files import (
|
||||
ComposedFinder,
|
||||
ManifestFile,
|
||||
)
|
||||
from mozpack.copier import (
|
||||
FileCopier,
|
||||
Jarrer,
|
||||
@ -177,9 +180,35 @@ def _repack(app_finder, l10n_finder, copier, formatter, non_chrome=set()):
|
||||
copier[path].preload([l.replace(locale, l10n_locale) for l in log])
|
||||
|
||||
|
||||
def repack(source, l10n, non_resources=[], non_chrome=set()):
|
||||
def repack(source, l10n, extra_l10n={}, non_resources=[], non_chrome=set()):
|
||||
'''
|
||||
Replace localized data from the `source` directory with localized data
|
||||
from `l10n` and `extra_l10n`.
|
||||
|
||||
The `source` argument points to a directory containing a packaged
|
||||
application (in omnijar, jar or flat form).
|
||||
The `l10n` argument points to a directory containing the main localized
|
||||
data (usually in the form of a language pack addon) to use to replace
|
||||
in the packaged application.
|
||||
The `extra_l10n` argument contains a dict associating relative paths in
|
||||
the source to separate directories containing localized data for them.
|
||||
This can be used to point at different language pack addons for different
|
||||
parts of the package application.
|
||||
The `non_resources` argument gives a list of relative paths in the source
|
||||
that should not be added in an omnijar in case the packaged application
|
||||
is in that format.
|
||||
The `non_chrome` argument gives a list of file/directory patterns for
|
||||
localized files that are not listed in a chrome.manifest.
|
||||
'''
|
||||
app_finder = UnpackFinder(source)
|
||||
l10n_finder = UnpackFinder(l10n)
|
||||
if extra_l10n:
|
||||
finders = {
|
||||
'': l10n_finder,
|
||||
}
|
||||
for base, path in extra_l10n.iteritems():
|
||||
finders[base] = UnpackFinder(path)
|
||||
l10n_finder = ComposedFinder(finders)
|
||||
copier = FileCopier()
|
||||
if app_finder.kind == 'flat':
|
||||
formatter = FlatFormatter(copier)
|
||||
|
@ -28,12 +28,23 @@ NON_CHROME = set([
|
||||
])
|
||||
|
||||
|
||||
def valid_extra_l10n(arg):
|
||||
if '=' not in arg:
|
||||
raise ValueError('Invalid value')
|
||||
return tuple(arg.split('=', 1))
|
||||
|
||||
|
||||
def main():
|
||||
parser = ArgumentParser()
|
||||
parser.add_argument('build',
|
||||
help='Directory containing the build to repack')
|
||||
parser.add_argument('l10n',
|
||||
help='Directory containing the staged langpack')
|
||||
parser.add_argument('extra_l10n', nargs='*', metavar='BASE=PATH',
|
||||
type=valid_extra_l10n,
|
||||
help='Extra directories with staged localized files '
|
||||
'to be considered under the given base in the '
|
||||
'repacked build')
|
||||
parser.add_argument('--non-resource', nargs='+', metavar='PATTERN',
|
||||
default=[],
|
||||
help='Extra files not to be considered as resources')
|
||||
@ -41,7 +52,8 @@ def main():
|
||||
|
||||
buildconfig.substs['USE_ELF_HACK'] = False
|
||||
buildconfig.substs['PKG_SKIP_STRIP'] = True
|
||||
l10n.repack(args.build, args.l10n, args.non_resource, NON_CHROME)
|
||||
l10n.repack(args.build, args.l10n, extra_l10n=dict(args.extra_l10n),
|
||||
non_resources=args.non_resource, non_chrome=NON_CHROME)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
Loading…
Reference in New Issue
Block a user