puppet 5.3.3-x64-mingw32 → 5.3.4-x64-mingw32
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of puppet might be problematic. Click here for more details.
- data/CONTRIBUTING.md +1 -1
- data/Gemfile +3 -0
- data/ext/puppet-test +3 -2
- data/lib/hiera/puppet_function.rb +5 -2
- data/lib/hiera_puppet.rb +3 -3
- data/lib/puppet.rb +2 -5
- data/lib/puppet/agent.rb +22 -2
- data/lib/puppet/agent/locker.rb +6 -5
- data/lib/puppet/application.rb +18 -1
- data/lib/puppet/application/agent.rb +9 -2
- data/lib/puppet/application/apply.rb +1 -1
- data/lib/puppet/application/config.rb +1 -0
- data/lib/puppet/application/device.rb +1 -2
- data/lib/puppet/application/filebucket.rb +22 -5
- data/lib/puppet/application/help.rb +1 -0
- data/lib/puppet/application/lookup.rb +1 -3
- data/lib/puppet/application_support.rb +6 -1
- data/lib/puppet/bindings.rb +2 -1
- data/lib/puppet/configurer.rb +9 -4
- data/lib/puppet/configurer/downloader_factory.rb +10 -0
- data/lib/puppet/configurer/plugin_handler.rb +11 -4
- data/lib/puppet/daemon.rb +2 -2
- data/lib/puppet/defaults.rb +99 -27
- data/lib/puppet/environments.rb +2 -0
- data/lib/puppet/error.rb +5 -15
- data/lib/puppet/external/pson/common.rb +2 -2
- data/lib/puppet/face/catalog.rb +1 -1
- data/lib/puppet/face/config.rb +14 -1
- data/lib/puppet/face/epp.rb +4 -2
- data/lib/puppet/face/help.rb +12 -14
- data/lib/puppet/face/man.rb +1 -0
- data/lib/puppet/face/module/build.rb +1 -1
- data/lib/puppet/face/module/list.rb +6 -17
- data/lib/puppet/face/module/uninstall.rb +14 -3
- data/lib/puppet/face/node.rb +1 -0
- data/lib/puppet/face/status.rb +1 -0
- data/lib/puppet/file_serving/base.rb +2 -1
- data/lib/puppet/file_serving/configuration.rb +3 -0
- data/lib/puppet/file_serving/configuration/parser.rb +23 -9
- data/lib/puppet/file_serving/mount/locales.rb +35 -0
- data/lib/puppet/forge.rb +2 -1
- data/lib/puppet/forge/errors.rb +24 -22
- data/lib/puppet/functions/binary_file.rb +1 -0
- data/lib/puppet/functions/each.rb +10 -4
- data/lib/puppet/functions/eyaml_lookup_key.rb +4 -2
- data/lib/puppet/functions/lookup.rb +2 -2
- data/lib/puppet/functions/map.rb +12 -2
- data/lib/puppet/functions/slice.rb +2 -3
- data/lib/puppet/functions/unique.rb +1 -1
- data/lib/puppet/functions/yaml_data.rb +1 -1
- data/lib/puppet/gettext/config.rb +144 -41
- data/lib/puppet/gettext/module_translations.rb +42 -0
- data/lib/puppet/graph/relationship_graph.rb +1 -1
- data/lib/puppet/graph/simple_graph.rb +3 -3
- data/lib/puppet/indirector/catalog/compiler.rb +40 -25
- data/lib/puppet/indirector/exec.rb +1 -1
- data/lib/puppet/indirector/facts/facter.rb +3 -3
- data/lib/puppet/indirector/facts/network_device.rb +2 -2
- data/lib/puppet/indirector/file_bucket_file/file.rb +4 -1
- data/lib/puppet/indirector/indirection.rb +17 -9
- data/lib/puppet/indirector/ldap.rb +2 -2
- data/lib/puppet/indirector/node/write_only_yaml.rb +3 -1
- data/lib/puppet/indirector/rest.rb +8 -5
- data/lib/puppet/indirector/ssl_file.rb +2 -2
- data/lib/puppet/indirector/terminus.rb +3 -3
- data/lib/puppet/interface.rb +2 -1
- data/lib/puppet/interface/action.rb +41 -24
- data/lib/puppet/interface/action_builder.rb +14 -5
- data/lib/puppet/interface/action_manager.rb +1 -1
- data/lib/puppet/interface/documentation.rb +21 -10
- data/lib/puppet/interface/face_collection.rb +4 -2
- data/lib/puppet/interface/option.rb +36 -15
- data/lib/puppet/interface/option_builder.rb +23 -9
- data/lib/puppet/interface/option_manager.rb +8 -3
- data/lib/puppet/metatype/manager.rb +7 -3
- data/lib/puppet/module.rb +18 -21
- data/lib/puppet/module_tool/errors/installer.rb +18 -20
- data/lib/puppet/module_tool/errors/shared.rb +20 -15
- data/lib/puppet/module_tool/errors/uninstaller.rb +1 -0
- data/lib/puppet/module_tool/errors/upgrader.rb +1 -1
- data/lib/puppet/module_tool/tar/mini.rb +57 -4
- data/lib/puppet/network/auth_config_parser.rb +18 -13
- data/lib/puppet/network/authstore.rb +2 -2
- data/lib/puppet/network/client_request.rb +1 -1
- data/lib/puppet/network/format.rb +3 -3
- data/lib/puppet/network/http/api/indirection_type.rb +1 -1
- data/lib/puppet/network/http/api/master/v3/environment.rb +5 -2
- data/lib/puppet/network/http/error.rb +7 -7
- data/lib/puppet/network/http/factory.rb +9 -0
- data/lib/puppet/network/http/rack.rb +2 -2
- data/lib/puppet/network/http/webrick.rb +2 -4
- data/lib/puppet/node.rb +25 -6
- data/lib/puppet/node/environment.rb +14 -0
- data/lib/puppet/node/facts.rb +9 -0
- data/lib/puppet/parameter.rb +3 -3
- data/lib/puppet/parameter/value_collection.rb +9 -9
- data/lib/puppet/parser/ast/leaf.rb +1 -1
- data/lib/puppet/parser/ast/node.rb +2 -2
- data/lib/puppet/parser/ast/pops_bridge.rb +1 -1
- data/lib/puppet/parser/compiler.rb +6 -5
- data/lib/puppet/parser/functions.rb +1 -1
- data/lib/puppet/parser/functions/generate.rb +2 -4
- data/lib/puppet/parser/functions/inline_template.rb +1 -2
- data/lib/puppet/parser/functions/sprintf.rb +17 -3
- data/lib/puppet/parser/functions/template.rb +6 -2
- data/lib/puppet/parser/resource.rb +30 -31
- data/lib/puppet/parser/scope.rb +20 -11
- data/lib/puppet/parser/templatewrapper.rb +4 -3
- data/lib/puppet/pops/evaluator/collector_transformer.rb +2 -1
- data/lib/puppet/pops/evaluator/collectors/abstract_collector.rb +1 -1
- data/lib/puppet/pops/evaluator/epp_evaluator.rb +21 -8
- data/lib/puppet/pops/evaluator/evaluator_impl.rb +2 -1
- data/lib/puppet/pops/evaluator/external_syntax_support.rb +1 -1
- data/lib/puppet/pops/evaluator/runtime3_converter.rb +3 -1
- data/lib/puppet/pops/evaluator/runtime3_resource_support.rb +1 -1
- data/lib/puppet/pops/evaluator/runtime3_support.rb +4 -4
- data/lib/puppet/pops/functions/dispatch.rb +1 -1
- data/lib/puppet/pops/functions/function.rb +8 -2
- data/lib/puppet/pops/issue_reporter.rb +7 -2
- data/lib/puppet/pops/issues.rb +10 -4
- data/lib/puppet/pops/label_provider.rb +1 -1
- data/lib/puppet/pops/loader/module_loaders.rb +5 -2
- data/lib/puppet/pops/loader/static_loader.rb +1 -1
- data/lib/puppet/pops/loaders.rb +7 -3
- data/lib/puppet/pops/lookup/explainer.rb +2 -1
- data/lib/puppet/pops/lookup/hiera_config.rb +2 -2
- data/lib/puppet/pops/lookup/lookup_adapter.rb +4 -4
- data/lib/puppet/pops/merge_strategy.rb +6 -3
- data/lib/puppet/pops/migration/migration_checker.rb +8 -8
- data/lib/puppet/pops/model/ast_transformer.rb +1 -1
- data/lib/puppet/pops/model/factory.rb +4 -2
- data/lib/puppet/pops/resource/resource_type_impl.rb +1 -1
- data/lib/puppet/pops/serialization/abstract_writer.rb +2 -1
- data/lib/puppet/pops/types/iterable.rb +2 -0
- data/lib/puppet/pops/types/p_object_type.rb +36 -15
- data/lib/puppet/pops/types/type_calculator.rb +2 -1
- data/lib/puppet/pops/types/type_factory.rb +3 -1
- data/lib/puppet/pops/types/type_mismatch_describer.rb +19 -6
- data/lib/puppet/pops/types/type_parser.rb +7 -7
- data/lib/puppet/pops/types/types.rb +10 -4
- data/lib/puppet/pops/validation.rb +14 -12
- data/lib/puppet/property.rb +14 -6
- data/lib/puppet/property/ensure.rb +2 -2
- data/lib/puppet/provider.rb +4 -4
- data/lib/puppet/provider/group/aix.rb +4 -2
- data/lib/puppet/provider/ldap.rb +2 -2
- data/lib/puppet/provider/naginator.rb +1 -1
- data/lib/puppet/provider/nameservice.rb +7 -4
- data/lib/puppet/provider/nameservice/directoryservice.rb +4 -3
- data/lib/puppet/provider/package/aix.rb +1 -1
- data/lib/puppet/provider/package/nim.rb +7 -8
- data/lib/puppet/provider/package/opkg.rb +1 -1
- data/lib/puppet/provider/package/pkg.rb +9 -6
- data/lib/puppet/provider/package/pkgutil.rb +3 -3
- data/lib/puppet/provider/package/yum.rb +1 -1
- data/lib/puppet/provider/parsedfile.rb +4 -4
- data/lib/puppet/provider/selmodule/semodule.rb +5 -3
- data/lib/puppet/provider/service/base.rb +1 -1
- data/lib/puppet/provider/service/init.rb +1 -1
- data/lib/puppet/provider/service/launchd.rb +2 -2
- data/lib/puppet/provider/service/runit.rb +2 -1
- data/lib/puppet/provider/service/smf.rb +2 -0
- data/lib/puppet/provider/service/systemd.rb +1 -0
- data/lib/puppet/provider/service/upstart.rb +1 -1
- data/lib/puppet/provider/user/aix.rb +13 -6
- data/lib/puppet/provider/user/openbsd.rb +2 -1
- data/lib/puppet/provider/yumrepo/inifile.rb +2 -1
- data/lib/puppet/provider/zone/solaris.rb +2 -2
- data/lib/puppet/reference/configuration.rb +4 -2
- data/lib/puppet/relationship.rb +2 -1
- data/lib/puppet/reports/store.rb +1 -1
- data/lib/puppet/resource.rb +7 -5
- data/lib/puppet/resource/capability_finder.rb +14 -11
- data/lib/puppet/resource/catalog.rb +33 -18
- data/lib/puppet/resource/type.rb +5 -5
- data/lib/puppet/settings.rb +19 -13
- data/lib/puppet/settings/base_setting.rb +23 -8
- data/lib/puppet/settings/config_file.rb +14 -4
- data/lib/puppet/settings/environment_conf.rb +19 -9
- data/lib/puppet/ssl/base.rb +9 -4
- data/lib/puppet/ssl/oids.rb +8 -2
- data/lib/puppet/syntax_checkers/base64.rb +5 -6
- data/lib/puppet/transaction.rb +7 -3
- data/lib/puppet/transaction/persistence.rb +16 -1
- data/lib/puppet/transaction/report.rb +6 -0
- data/lib/puppet/type.rb +27 -35
- data/lib/puppet/type/file.rb +2 -1
- data/lib/puppet/type/file/data_sync.rb +2 -1
- data/lib/puppet/type/file/source.rb +1 -1
- data/lib/puppet/type/group.rb +1 -1
- data/lib/puppet/type/mount.rb +1 -1
- data/lib/puppet/type/resources.rb +1 -1
- data/lib/puppet/type/schedule.rb +26 -14
- data/lib/puppet/type/user.rb +9 -3
- data/lib/puppet/type/zone.rb +1 -1
- data/lib/puppet/util.rb +27 -21
- data/lib/puppet/util/at_fork/solaris.rb +6 -4
- data/lib/puppet/util/command_line.rb +5 -0
- data/lib/puppet/util/command_line/trollop.rb +6 -5
- data/lib/puppet/util/errors.rb +61 -8
- data/lib/puppet/util/fileparsing.rb +3 -5
- data/lib/puppet/util/http_proxy.rb +14 -6
- data/lib/puppet/util/instance_loader.rb +1 -3
- data/lib/puppet/util/ldap/manager.rb +6 -3
- data/lib/puppet/util/log.rb +19 -24
- data/lib/puppet/util/logging.rb +21 -28
- data/lib/puppet/util/methodhelper.rb +1 -1
- data/lib/puppet/util/nagios_maker.rb +1 -1
- data/lib/puppet/util/network_device/config.rb +21 -13
- data/lib/puppet/util/plist.rb +3 -1
- data/lib/puppet/util/posix.rb +1 -1
- data/lib/puppet/util/provider_features.rb +1 -1
- data/lib/puppet/util/rdoc/generators/puppet_generator.rb +1 -1
- data/lib/puppet/util/reference.rb +2 -3
- data/lib/puppet/util/selinux.rb +1 -1
- data/lib/puppet/util/storage.rb +2 -2
- data/lib/puppet/util/windows/eventlog.rb +10 -5
- data/lib/puppet/util/windows/file.rb +61 -9
- data/lib/puppet/util/windows/process.rb +1 -1
- data/lib/puppet/util/windows/taskscheduler.rb +2 -2
- data/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet.rb +5 -1
- data/lib/puppet/version.rb +1 -1
- data/locales/en/puppet.po +19 -0
- data/locales/ja/puppet.po +2739 -809
- data/locales/puppet.pot +2367 -734
- data/spec/fixtures/unit/application/environments/production/data/common.yaml +2 -0
- data/spec/integration/agent/logging_spec.rb +2 -0
- data/spec/integration/faces/plugin_spec.rb +1 -0
- data/spec/integration/network/authconfig_spec.rb +2 -2
- data/spec/integration/parser/collection_spec.rb +2 -2
- data/spec/integration/parser/scope_spec.rb +16 -3
- data/spec/integration/provider/cron/crontab_spec.rb +1 -0
- data/spec/integration/transaction/report_spec.rb +5 -0
- data/spec/lib/matchers/json.rb +14 -13
- data/spec/unit/agent_spec.rb +33 -0
- data/spec/unit/application/config_spec.rb +4 -0
- data/spec/unit/application/lookup_spec.rb +30 -0
- data/spec/unit/application_spec.rb +18 -0
- data/spec/unit/configurer/downloader_factory_spec.rb +33 -0
- data/spec/unit/configurer/plugin_handler_spec.rb +71 -16
- data/spec/unit/environments_spec.rb +15 -0
- data/spec/unit/face/config_spec.rb +8 -9
- data/spec/unit/face/epp_face_spec.rb +2 -2
- data/spec/unit/face/plugin_spec.rb +50 -4
- data/spec/unit/file_serving/configuration/parser_spec.rb +2 -2
- data/spec/unit/file_serving/mount/locales_spec.rb +73 -0
- data/spec/unit/functions/break_spec.rb +108 -50
- data/spec/unit/functions/defined_spec.rb +2 -2
- data/spec/unit/functions/hiera_spec.rb +0 -1
- data/spec/unit/functions/lookup_spec.rb +85 -19
- data/spec/unit/functions/next_spec.rb +1 -1
- data/spec/unit/functions/return_spec.rb +2 -2
- data/spec/unit/gettext/config_spec.rb +125 -0
- data/spec/unit/gettext/module_loading_spec.rb +53 -0
- data/spec/unit/indirector/json_spec.rb +0 -11
- data/spec/unit/indirector/node/exec_spec.rb +1 -1
- data/spec/unit/info_service_spec.rb +1 -1
- data/spec/unit/interface_spec.rb +12 -0
- data/spec/unit/module_spec.rb +0 -28
- data/spec/unit/module_tool/tar/mini_spec.rb +34 -5
- data/spec/unit/network/http/factory_spec.rb +22 -0
- data/spec/unit/network/http/webrick_spec.rb +30 -29
- data/spec/unit/node/environment_spec.rb +16 -0
- data/spec/unit/node_spec.rb +102 -16
- data/spec/unit/parser/environment_compiler_spec.rb +1 -1
- data/spec/unit/parser/functions/sprintf_spec.rb +26 -0
- data/spec/unit/parser/resource/param_spec.rb +1 -1
- data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +9 -9
- data/spec/unit/pops/loaders/static_loader_spec.rb +1 -1
- data/spec/unit/pops/parser/parse_containers_spec.rb +1 -1
- data/spec/unit/pops/types/type_calculator_spec.rb +40 -0
- data/spec/unit/pops/types/type_mismatch_describer_spec.rb +9 -0
- data/spec/unit/provider/selmodule_spec.rb +6 -0
- data/spec/unit/provider/service/init_spec.rb +1 -1
- data/spec/unit/provider/service/smf_spec.rb +2 -0
- data/spec/unit/provider/service/systemd_spec.rb +14 -0
- data/spec/unit/resource/catalog_spec.rb +12 -2
- data/spec/unit/settings/config_file_spec.rb +1 -1
- data/spec/unit/transaction/persistence_spec.rb +42 -0
- data/spec/unit/transaction/report_spec.rb +19 -4
- data/spec/unit/transaction_spec.rb +27 -0
- data/spec/unit/type/schedule_spec.rb +14 -0
- data/spec/unit/type_spec.rb +3 -3
- data/spec/unit/util/errors_spec.rb +1 -1
- data/spec/unit/util/http_proxy_spec.rb +37 -0
- data/spec/unit/util/log_spec.rb +3 -3
- data/spec/unit/util/logging_spec.rb +7 -7
- data/spec/unit/util/monkey_patches_spec.rb +6 -2
- metadata +3445 -3416
- checksums.yaml +0 -7
- data/spec/unit/gettext_config_spec.rb +0 -57
@@ -63,7 +63,13 @@ Puppet::Face.define(:module, '1.0.0') do
|
|
63
63
|
name = name.gsub('/', '-')
|
64
64
|
|
65
65
|
Puppet::ModuleTool.set_option_defaults options
|
66
|
-
|
66
|
+
message = if options[:version]
|
67
|
+
module_version = colorize(:cyan, options[:version].sub(/^(?=\d)/, 'v'))
|
68
|
+
_("Preparing to uninstall '%{name}' (%{module_version}) ...") % { name: name, module_version: module_version }
|
69
|
+
else
|
70
|
+
_("Preparing to uninstall '%{name}' ...") % { name: name }
|
71
|
+
end
|
72
|
+
Puppet.notice message
|
67
73
|
Puppet::ModuleTool::Applications::Uninstaller.run(name, options)
|
68
74
|
end
|
69
75
|
|
@@ -73,8 +79,13 @@ Puppet::Face.define(:module, '1.0.0') do
|
|
73
79
|
exit 1
|
74
80
|
else
|
75
81
|
mod = return_value[:affected_modules].first
|
76
|
-
|
77
|
-
|
82
|
+
message = if mod.version
|
83
|
+
module_version = colorize(:cyan, mod.version.to_s.sub(/^(?=\d)/, 'v'))
|
84
|
+
_("Removed '%{name}' (%{module_version}) from %{path}") % { name: return_value[:module_name], module_version: module_version, path: mod.modulepath }
|
85
|
+
else
|
86
|
+
_("Removed '%{name}' from %{path}") % { name: return_value[:module_name], path: mod.modulepath }
|
87
|
+
end
|
88
|
+
message
|
78
89
|
end
|
79
90
|
end
|
80
91
|
end
|
data/lib/puppet/face/node.rb
CHANGED
@@ -17,6 +17,7 @@ Puppet::Indirector::Face.define(:node, '0.0.1') do
|
|
17
17
|
find = get_action(:find)
|
18
18
|
find.summary _("Retrieve a node object.")
|
19
19
|
find.arguments _("<host>")
|
20
|
+
#TRANSLATORS the following are specific names and should not be translated `classes`, `environment`, `expiration`, `name`, `parameters`, Puppet::Node
|
20
21
|
find.returns _(<<-'EOT')
|
21
22
|
A hash containing the node's `classes`, `environment`, `expiration`, `name`,
|
22
23
|
`parameters` (its facts, combined with any ENC-set parameters), and `time`.
|
data/lib/puppet/face/status.rb
CHANGED
@@ -13,6 +13,7 @@ Puppet::Indirector::Face.define(:status, '0.0.1') do
|
|
13
13
|
find = get_action(:find)
|
14
14
|
find.default = true
|
15
15
|
find.summary _("Check status of puppet master server.")
|
16
|
+
#TRANSLATORS the string 'Puppet::Status' is a Puppet language object and should not be translated
|
16
17
|
find.returns _(<<-'EOT')
|
17
18
|
A "true" response or a low-level connection error. When used from the Ruby
|
18
19
|
API: returns a Puppet::Status object.
|
@@ -46,7 +46,8 @@ class Puppet::FileServing::Base
|
|
46
46
|
def links=(value)
|
47
47
|
value = value.to_sym
|
48
48
|
value = :manage if value == :ignore
|
49
|
-
|
49
|
+
#TRANSLATORS ':link', ':manage', ':follow' should not be translated
|
50
|
+
raise(ArgumentError, _(":links can only be set to :manage or :follow")) unless [:manage, :follow].include?(value)
|
50
51
|
@links = value
|
51
52
|
end
|
52
53
|
|
@@ -4,6 +4,7 @@ require 'puppet/file_serving/mount'
|
|
4
4
|
require 'puppet/file_serving/mount/file'
|
5
5
|
require 'puppet/file_serving/mount/modules'
|
6
6
|
require 'puppet/file_serving/mount/plugins'
|
7
|
+
require 'puppet/file_serving/mount/locales'
|
7
8
|
require 'puppet/file_serving/mount/pluginfacts'
|
8
9
|
require 'puppet/file_serving/mount/tasks'
|
9
10
|
|
@@ -81,6 +82,8 @@ class Puppet::FileServing::Configuration
|
|
81
82
|
@mounts["modules"].allow('*') if @mounts["modules"].empty?
|
82
83
|
@mounts["plugins"] ||= Mount::Plugins.new("plugins")
|
83
84
|
@mounts["plugins"].allow('*') if @mounts["plugins"].empty?
|
85
|
+
@mounts["locales"] ||= Mount::Locales.new("locales")
|
86
|
+
@mounts["locales"].allow('*') if @mounts["locales"].empty?
|
84
87
|
@mounts["pluginfacts"] ||= Mount::PluginFacts.new("pluginfacts")
|
85
88
|
@mounts["pluginfacts"].allow('*') if @mounts["pluginfacts"].empty?
|
86
89
|
@mounts["tasks"] ||= Mount::Tasks.new("tasks")
|
@@ -13,9 +13,9 @@ class Puppet::FileServing::Configuration::Parser
|
|
13
13
|
@mounts = {}
|
14
14
|
@count = 0
|
15
15
|
|
16
|
-
File.open(@file)
|
16
|
+
File.open(@file) do |f|
|
17
17
|
mount = nil
|
18
|
-
f.each_line
|
18
|
+
f.each_line do |line|
|
19
19
|
# Have the count increment at the top, in case we throw exceptions.
|
20
20
|
@count += 1
|
21
21
|
|
@@ -37,13 +37,17 @@ class Puppet::FileServing::Configuration::Parser
|
|
37
37
|
when "deny"
|
38
38
|
deny(mount, value)
|
39
39
|
else
|
40
|
-
|
40
|
+
error_location_str = Puppet::Util::Errors.error_location(@file.filename, @count)
|
41
|
+
raise ArgumentError.new(_("Invalid argument '%{var}' at %{error_location}") %
|
42
|
+
{ var: var, error_location: error_location_str })
|
41
43
|
end
|
42
44
|
else
|
43
|
-
|
45
|
+
error_location_str = Puppet::Util::Errors.error_location(@file.filename, @count)
|
46
|
+
raise ArgumentError.new(_("Invalid entry at %{error_location}: '%{file_text}'") %
|
47
|
+
{ file_text: line.chomp, error_location: error_location_str })
|
44
48
|
end
|
45
|
-
|
46
|
-
|
49
|
+
end
|
50
|
+
end
|
47
51
|
|
48
52
|
validate
|
49
53
|
|
@@ -67,7 +71,9 @@ class Puppet::FileServing::Configuration::Parser
|
|
67
71
|
mount.info _("allowing %{val} access") % { val: val }
|
68
72
|
mount.allow(val)
|
69
73
|
rescue Puppet::AuthStoreError => detail
|
70
|
-
|
74
|
+
error_location_str = Puppet::Util::Errors.error_location(@file, @count)
|
75
|
+
raise ArgumentError.new("%{detail} %{error_location}" %
|
76
|
+
{ detail: detail.to_s, error_location: error_location_str })
|
71
77
|
end
|
72
78
|
}
|
73
79
|
end
|
@@ -79,14 +85,20 @@ class Puppet::FileServing::Configuration::Parser
|
|
79
85
|
mount.info _("denying %{val} access") % { val: val }
|
80
86
|
mount.deny(val)
|
81
87
|
rescue Puppet::AuthStoreError => detail
|
82
|
-
|
88
|
+
error_location_str = Puppet::Util::Errors.error_location(@file, @count)
|
89
|
+
raise ArgumentError.new("%{detail} %{error_location}" %
|
90
|
+
{ detail: detail.to_s, error_location: error_location_str })
|
83
91
|
end
|
84
92
|
}
|
85
93
|
end
|
86
94
|
|
87
95
|
# Create a new mount.
|
88
96
|
def newmount(name)
|
89
|
-
|
97
|
+
if @mounts.include?(name)
|
98
|
+
error_location_str = Puppet::Util::Errors.error_location(@file, @count)
|
99
|
+
raise ArgumentError.new(_("%{mount} is already mounted at %{name} at %{error_location}") %
|
100
|
+
{ mount: @mounts[name], name: name, error_location: error_location_str })
|
101
|
+
end
|
90
102
|
case name
|
91
103
|
when "modules"
|
92
104
|
mount = Mount::Modules.new(name)
|
@@ -94,6 +106,8 @@ class Puppet::FileServing::Configuration::Parser
|
|
94
106
|
mount = Mount::Plugins.new(name)
|
95
107
|
when "tasks"
|
96
108
|
mount = Mount::Tasks.new(name)
|
109
|
+
when "locales"
|
110
|
+
mount = Mount::Locales.new(name)
|
97
111
|
else
|
98
112
|
mount = Mount::File.new(name)
|
99
113
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'puppet/file_serving/mount'
|
2
|
+
|
3
|
+
# Find files in the modules' locales directories.
|
4
|
+
# This is a very strange mount because it merges
|
5
|
+
# many directories into one.
|
6
|
+
class Puppet::FileServing::Mount::Locales < Puppet::FileServing::Mount
|
7
|
+
# Return an instance of the appropriate class.
|
8
|
+
def find(relative_path, request)
|
9
|
+
return nil unless mod = request.environment.modules.find { |m| m.locale(relative_path) }
|
10
|
+
|
11
|
+
path = mod.locale(relative_path)
|
12
|
+
|
13
|
+
path
|
14
|
+
end
|
15
|
+
|
16
|
+
def search(relative_path, request)
|
17
|
+
# We currently only support one kind of search on locales - return
|
18
|
+
# them all.
|
19
|
+
Puppet.debug("Warning: calling Locales.search with empty module path.") if request.environment.modules.empty?
|
20
|
+
paths = request.environment.modules.find_all { |mod| mod.locales? }.collect { |mod| mod.locale_directory }
|
21
|
+
if paths.empty?
|
22
|
+
# If the modulepath is valid then we still need to return a valid root
|
23
|
+
# directory for the search, but make sure nothing inside it is
|
24
|
+
# returned.
|
25
|
+
request.options[:recurse] = false
|
26
|
+
request.environment.modulepath.empty? ? nil : request.environment.modulepath
|
27
|
+
else
|
28
|
+
paths
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def valid?
|
33
|
+
true
|
34
|
+
end
|
35
|
+
end
|
data/lib/puppet/forge.rb
CHANGED
@@ -134,7 +134,8 @@ class Puppet::Forge < SemanticPuppet::Dependency::Source
|
|
134
134
|
Puppet::ModuleTool::Metadata.new.add_dependency(dep['name'], dep['version_requirement'], dep['repository'])
|
135
135
|
Puppet::ModuleTool.parse_module_dependency(release, dep, strict_semver)[0..1]
|
136
136
|
rescue ArgumentError => e
|
137
|
-
raise ArgumentError, "Malformed dependency:
|
137
|
+
raise ArgumentError, _("Malformed dependency: %{name}.") % { name: dep['name'] } +
|
138
|
+
' ' + _("Exception was: %{detail}") % { detail: e }
|
138
139
|
end
|
139
140
|
end
|
140
141
|
else
|
data/lib/puppet/forge/errors.rb
CHANGED
@@ -32,12 +32,12 @@ module Puppet::Forge::Errors
|
|
32
32
|
#
|
33
33
|
# @return [String] the multiline version of the error message
|
34
34
|
def multiline
|
35
|
-
|
36
|
-
Could not connect via HTTPS to %{uri}
|
37
|
-
Unable to verify the SSL certificate
|
38
|
-
The certificate may not be signed by a valid CA
|
39
|
-
The CA bundle included with OpenSSL may not be valid or up to date
|
40
|
-
|
35
|
+
message = []
|
36
|
+
message << _('Could not connect via HTTPS to %{uri}') % { uri: @uri }
|
37
|
+
message << _(' Unable to verify the SSL certificate')
|
38
|
+
message << _(' The certificate may not be signed by a valid CA')
|
39
|
+
message << _(' The CA bundle included with OpenSSL may not be valid or up to date')
|
40
|
+
message.join("\n")
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
@@ -59,12 +59,12 @@ Could not connect via HTTPS to %{uri}
|
|
59
59
|
#
|
60
60
|
# @return [String] the multiline version of the error message
|
61
61
|
def multiline
|
62
|
-
|
63
|
-
Could not connect to %{uri}
|
64
|
-
There was a network communications problem
|
65
|
-
The error we caught said '%{detail}'
|
66
|
-
Check your network connection and try again
|
67
|
-
|
62
|
+
message = []
|
63
|
+
message << _('Could not connect to %{uri}') % { uri: @uri }
|
64
|
+
message << _(' There was a network communications problem')
|
65
|
+
message << _(" The error we caught said '%{detail}'") % { detail: @detail }
|
66
|
+
message << _(' Check your network connection and try again')
|
67
|
+
message.join("\n")
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
@@ -89,9 +89,11 @@ Could not connect to %{uri}
|
|
89
89
|
rescue JSON::ParserError
|
90
90
|
end
|
91
91
|
|
92
|
-
message =
|
93
|
-
|
94
|
-
|
92
|
+
message = if @message
|
93
|
+
_("Request to Puppet Forge failed.") + ' ' + _("Detail: %{detail}.") % { detail: "#{@message} / #{@response}" }
|
94
|
+
else
|
95
|
+
_("Request to Puppet Forge failed.") + ' ' + _("Detail: %{detail}.") % { detail: @response }
|
96
|
+
end
|
95
97
|
super(message, original)
|
96
98
|
end
|
97
99
|
|
@@ -99,13 +101,13 @@ Could not connect to %{uri}
|
|
99
101
|
#
|
100
102
|
# @return [String] the multiline version of the error message
|
101
103
|
def multiline
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
The
|
106
|
-
|
107
|
-
message << _("
|
108
|
-
message
|
104
|
+
|
105
|
+
message = []
|
106
|
+
message << _('Request to Puppet Forge failed.')
|
107
|
+
message << _(' The server being queried was %{uri}') % { uri: @uri }
|
108
|
+
message << _(" The HTTP response we received was '%{response}'") % { response: @response }
|
109
|
+
message << _(" The message we received said '%{message}'") % { message: @message } if @message
|
110
|
+
message.join("\n")
|
109
111
|
end
|
110
112
|
end
|
111
113
|
|
@@ -12,6 +12,7 @@ Puppet::Functions.create_function(:binary_file, Puppet::Functions::InternalFunct
|
|
12
12
|
def binary_file(scope, unresolved_path)
|
13
13
|
path = Puppet::Parser::Files.find_file(unresolved_path, scope.compiler.environment)
|
14
14
|
unless path && Puppet::FileSystem.exist?(path)
|
15
|
+
#TRANSLATORS the string "binary_file()" should not be translated
|
15
16
|
raise Puppet::ParseError, _("binary_file(): The given file '%{unresolved_path}' does not exist") % { unresolved_path: unresolved_path }
|
16
17
|
end
|
17
18
|
Puppet::Pops::Types::PBinaryType::Binary.from_binary_string(Puppet::FileSystem.binread(path))
|
@@ -117,8 +117,11 @@ Puppet::Functions.create_function(:each) do
|
|
117
117
|
|
118
118
|
def foreach_Hash_1(hash)
|
119
119
|
enumerator = hash.each_pair
|
120
|
-
|
121
|
-
|
120
|
+
begin
|
121
|
+
hash.size.times do
|
122
|
+
yield(enumerator.next)
|
123
|
+
end
|
124
|
+
rescue StopIteration
|
122
125
|
end
|
123
126
|
# produces the receiver
|
124
127
|
hash
|
@@ -126,8 +129,11 @@ Puppet::Functions.create_function(:each) do
|
|
126
129
|
|
127
130
|
def foreach_Hash_2(hash)
|
128
131
|
enumerator = hash.each_pair
|
129
|
-
|
130
|
-
|
132
|
+
begin
|
133
|
+
hash.size.times do
|
134
|
+
yield(*enumerator.next)
|
135
|
+
end
|
136
|
+
rescue StopIteration
|
131
137
|
end
|
132
138
|
# produces the receiver
|
133
139
|
hash
|
@@ -26,8 +26,10 @@ Puppet::Functions.create_function(:eyaml_lookup_key) do
|
|
26
26
|
# Can't do this with an argument_mismatch dispatcher since there is no way to declare a struct that at least
|
27
27
|
# contains some keys but may contain other arbitrary keys.
|
28
28
|
unless options.include?('path')
|
29
|
+
#TRANSLATORS 'eyaml_lookup_key':, 'path', 'paths' 'glob', 'globs', 'mapped_paths', and lookup_key should not be translated
|
29
30
|
raise ArgumentError,
|
30
|
-
"'eyaml_lookup_key': one of 'path', 'paths' 'glob', 'globs' or 'mapped_paths' must be declared in hiera.yaml
|
31
|
+
_("'eyaml_lookup_key': one of 'path', 'paths' 'glob', 'globs' or 'mapped_paths' must be declared in hiera.yaml"\
|
32
|
+
" when using this lookup_key function")
|
31
33
|
end
|
32
34
|
|
33
35
|
# nil key is used to indicate that the cache contains the raw content of the eyaml file
|
@@ -48,7 +50,7 @@ Puppet::Functions.create_function(:eyaml_lookup_key) do
|
|
48
50
|
if data.is_a?(Hash)
|
49
51
|
Puppet::Pops::Lookup::HieraConfig.symkeys_to_string(data)
|
50
52
|
else
|
51
|
-
Puppet.warning("
|
53
|
+
Puppet.warning(_("%{path}: file does not contain a valid yaml hash") % { path: path })
|
52
54
|
{}
|
53
55
|
end
|
54
56
|
rescue YAML::SyntaxError => ex
|
@@ -91,8 +91,8 @@
|
|
91
91
|
# merged hash. If the same key exists in multiple source hashes, Puppet will
|
92
92
|
# recursively merge hash or array values (with duplicate values removed from
|
93
93
|
# arrays). For conflicting scalar values, the highest-priority value will win.
|
94
|
-
# * `{'strategy' => 'first
|
95
|
-
# merge behaviors.
|
94
|
+
# * `{'strategy' => 'first'}`, `{'strategy' => 'unique'}`,
|
95
|
+
# or `{'strategy' => 'hash'}` --- Same as the string versions of these merge behaviors.
|
96
96
|
# * `{'strategy' => 'deep', <DEEP OPTION> => <VALUE>, ...}` --- Same as `'deep'`,
|
97
97
|
# but can adjust the merge with additional options. The available options are:
|
98
98
|
# * `'knockout_prefix'` (string or undef) --- A string prefix to indicate a
|
data/lib/puppet/functions/map.rb
CHANGED
@@ -88,11 +88,21 @@ Puppet::Functions.create_function(:map) do
|
|
88
88
|
end
|
89
89
|
|
90
90
|
def map_Hash_1(hash)
|
91
|
-
|
91
|
+
result = []
|
92
|
+
begin
|
93
|
+
hash.map {|x, y| result << yield([x, y]) }
|
94
|
+
rescue StopIteration
|
95
|
+
end
|
96
|
+
result
|
92
97
|
end
|
93
98
|
|
94
99
|
def map_Hash_2(hash)
|
95
|
-
|
100
|
+
result = []
|
101
|
+
begin
|
102
|
+
hash.map {|x, y| result << yield(x, y) }
|
103
|
+
rescue StopIteration
|
104
|
+
end
|
105
|
+
result
|
96
106
|
end
|
97
107
|
|
98
108
|
def map_Enumerable_1(enumerable)
|
@@ -102,9 +102,8 @@ Puppet::Functions.create_function(:slice) do
|
|
102
102
|
raise ArgumentError, _("slice(): block must define at least one parameter. Block has 0.")
|
103
103
|
end
|
104
104
|
unless serving_size == 1 || serving_size == slice_size
|
105
|
-
raise ArgumentError, _("slice(): block must define one parameter, or ")
|
106
|
-
|
107
|
-
pblock.parameter_names.join(', ')
|
105
|
+
raise ArgumentError, _("slice(): block must define one parameter, or the same number of parameters as the given size of the slice (%{slice_size}). Block has %{serving_size}; %{parameter_names}") %
|
106
|
+
{ slice_size: slice_size, serving_size: serving_size, parameter_names: pblock.parameter_names.join(', ') }
|
108
107
|
end
|
109
108
|
serving_size
|
110
109
|
end
|
@@ -25,7 +25,7 @@ Puppet::Functions.create_function(:yaml_data) do
|
|
25
25
|
if data.is_a?(Hash)
|
26
26
|
Puppet::Pops::Lookup::HieraConfig.symkeys_to_string(data)
|
27
27
|
else
|
28
|
-
Puppet.warning("
|
28
|
+
Puppet.warning(_("%{path}: file does not contain a valid yaml hash" % { path: path }))
|
29
29
|
{}
|
30
30
|
end
|
31
31
|
rescue YAML::SyntaxError => ex
|
@@ -6,9 +6,10 @@ module Puppet::GettextConfig
|
|
6
6
|
POSIX_PATH = File.absolute_path('../../../../../share/locale', File.dirname(__FILE__))
|
7
7
|
WINDOWS_PATH = File.absolute_path('../../../../../../../puppet/share/locale', File.dirname(__FILE__))
|
8
8
|
|
9
|
+
DEFAULT_TEXT_DOMAIN = 'default-text-domain'
|
10
|
+
|
9
11
|
# Load gettext helpers and track whether they're available.
|
10
12
|
# Used instead of features because we initialize gettext before features is available.
|
11
|
-
# Stubbing gettext if unavailable is handled in puppet.rb.
|
12
13
|
begin
|
13
14
|
require 'fast_gettext'
|
14
15
|
require 'locale'
|
@@ -34,33 +35,128 @@ module Puppet::GettextConfig
|
|
34
35
|
end
|
35
36
|
|
36
37
|
# @api private
|
37
|
-
#
|
38
|
-
#
|
39
|
-
# @return [
|
40
|
-
def self.
|
41
|
-
|
42
|
-
|
43
|
-
return true
|
38
|
+
# Returns the currently selected locale from FastGettext,
|
39
|
+
# or 'en' of gettext has not been loaded
|
40
|
+
# @return [String] the active locale
|
41
|
+
def self.current_locale
|
42
|
+
if gettext_loaded?
|
43
|
+
return FastGettext.default_locale
|
44
44
|
else
|
45
|
-
return
|
45
|
+
return 'en'
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
49
|
# @api private
|
50
|
-
#
|
51
|
-
#
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
return
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
50
|
+
# Returns a list of the names of the loaded text domains
|
51
|
+
# @return [[String]] the names of the loaded text domains
|
52
|
+
def self.loaded_text_domains
|
53
|
+
return [] if @gettext_disabled || !gettext_loaded?
|
54
|
+
|
55
|
+
return FastGettext.translation_repositories.keys
|
56
|
+
end
|
57
|
+
|
58
|
+
# @api private
|
59
|
+
# Clears the translation repository for the given text domain,
|
60
|
+
# creating it if it doesn't exist, then adds default translations
|
61
|
+
# and switches to using this domain.
|
62
|
+
# @param [String] domain_name the name of the domain to create
|
63
|
+
def self.reset_text_domain(domain_name)
|
64
|
+
return if @gettext_disabled || !gettext_loaded?
|
65
|
+
|
66
|
+
FastGettext.add_text_domain(domain_name,
|
67
|
+
type: :chain,
|
68
|
+
chain: [],
|
69
|
+
report_warning: false)
|
70
|
+
copy_default_translations(domain_name)
|
61
71
|
FastGettext.text_domain = domain_name
|
62
72
|
end
|
63
73
|
|
74
|
+
# @api private
|
75
|
+
# Creates a default text domain containing the translations for
|
76
|
+
# Puppet as the start of chain. When semantic_puppet gets initialized,
|
77
|
+
# its translations are added to this chain. This is used as a cache
|
78
|
+
# so that all non-module translations only need to be loaded once as
|
79
|
+
# we create and reset environment-specific text domains.
|
80
|
+
#
|
81
|
+
# @return true if Puppet translations were successfully loaded, false
|
82
|
+
# otherwise
|
83
|
+
def self.create_default_text_domain
|
84
|
+
return if @gettext_disabled || !gettext_loaded?
|
85
|
+
|
86
|
+
FastGettext.add_text_domain(DEFAULT_TEXT_DOMAIN,
|
87
|
+
type: :chain,
|
88
|
+
chain: [],
|
89
|
+
report_warning: false)
|
90
|
+
FastGettext.default_text_domain = DEFAULT_TEXT_DOMAIN
|
91
|
+
|
92
|
+
load_translations('puppet', puppet_locale_path, translation_mode(puppet_locale_path), DEFAULT_TEXT_DOMAIN)
|
93
|
+
end
|
94
|
+
|
95
|
+
# @api private
|
96
|
+
# Switches the active text domain, if the requested domain exists.
|
97
|
+
# @param [String] domain_name the name of the domain to switch to
|
98
|
+
def self.use_text_domain(domain_name)
|
99
|
+
return if @gettext_disabled || !gettext_loaded?
|
100
|
+
|
101
|
+
if FastGettext.translation_repositories.include?(domain_name)
|
102
|
+
FastGettext.text_domain = domain_name
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
# @api private
|
107
|
+
# Delete all text domains.
|
108
|
+
def self.delete_all_text_domains
|
109
|
+
FastGettext.translation_repositories.clear
|
110
|
+
FastGettext.default_text_domain = nil
|
111
|
+
FastGettext.text_domain = nil
|
112
|
+
end
|
113
|
+
|
114
|
+
# @api private
|
115
|
+
# Deletes the text domain with the given name
|
116
|
+
# @param [String] domain_name the name of the domain to delete
|
117
|
+
def self.delete_text_domain(domain_name)
|
118
|
+
return if @gettext_disabled || !gettext_loaded?
|
119
|
+
|
120
|
+
FastGettext.translation_repositories.delete(domain_name)
|
121
|
+
if FastGettext.text_domain == domain_name
|
122
|
+
FastGettext.text_domain = nil
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
# @api private
|
127
|
+
# Deletes all text domains except the default one
|
128
|
+
def self.delete_environment_text_domains
|
129
|
+
return if @gettext_disabled || !gettext_loaded?
|
130
|
+
|
131
|
+
FastGettext.translation_repositories.keys.each do |key|
|
132
|
+
# do not clear default translations
|
133
|
+
next if key == DEFAULT_TEXT_DOMAIN
|
134
|
+
|
135
|
+
FastGettext.translation_repositories.delete(key)
|
136
|
+
end
|
137
|
+
FastGettext.text_domain = nil
|
138
|
+
end
|
139
|
+
|
140
|
+
# @api private
|
141
|
+
# Adds translations from the default text domain to the specified
|
142
|
+
# text domain. Creates the default text domain if one does not exist
|
143
|
+
# (this will load Puppet's translations).
|
144
|
+
#
|
145
|
+
# Since we are currently (Nov 2017) vendoring semantic_puppet, in normal
|
146
|
+
# flows these translations will be copied along with Puppet's.
|
147
|
+
#
|
148
|
+
# @param [String] domain_name the name of the domain to add translations to
|
149
|
+
def self.copy_default_translations(domain_name)
|
150
|
+
return if @gettext_disabled || !gettext_loaded?
|
151
|
+
|
152
|
+
if FastGettext.default_text_domain.nil?
|
153
|
+
create_default_text_domain
|
154
|
+
end
|
155
|
+
|
156
|
+
puppet_translations = FastGettext.translation_repositories[FastGettext.default_text_domain].chain
|
157
|
+
FastGettext.translation_repositories[domain_name].chain.push(*puppet_translations)
|
158
|
+
end
|
159
|
+
|
64
160
|
# @api private
|
65
161
|
# Search for puppet gettext config files
|
66
162
|
# @return [String] path to the config, or nil if not found
|
@@ -78,7 +174,7 @@ module Puppet::GettextConfig
|
|
78
174
|
|
79
175
|
# @api private
|
80
176
|
# Determine which translation file format to use
|
81
|
-
# @param
|
177
|
+
# @param [String] conf_path the path to the gettext config file
|
82
178
|
# @return [Symbol] :mo if in a package structure, :po otherwise
|
83
179
|
def self.translation_mode(conf_path)
|
84
180
|
if WINDOWS_PATH == conf_path || POSIX_PATH == conf_path
|
@@ -96,11 +192,15 @@ module Puppet::GettextConfig
|
|
96
192
|
|
97
193
|
# @api private
|
98
194
|
# Attempt to load tranlstions for the given project.
|
99
|
-
# @param
|
100
|
-
# @param
|
101
|
-
# @param
|
195
|
+
# @param [String] project_name the project whose translations we want to load
|
196
|
+
# @param [String] locale_dir the path to the directory containing translations
|
197
|
+
# @param [Symbol] file_format translation file format to use, either :po or :mo
|
102
198
|
# @return true if initialization succeeded, false otherwise
|
103
|
-
def self.load_translations(project_name, locale_dir, file_format)
|
199
|
+
def self.load_translations(project_name, locale_dir, file_format, text_domain = FastGettext.text_domain)
|
200
|
+
if project_name.nil? || project_name.empty?
|
201
|
+
raise Puppet::Error, "A project name must be specified in order to initialize translations."
|
202
|
+
end
|
203
|
+
|
104
204
|
return false if @gettext_disabled || !@gettext_loaded
|
105
205
|
|
106
206
|
return false unless locale_dir && Puppet::FileSystem.exist?(locale_dir)
|
@@ -109,38 +209,41 @@ module Puppet::GettextConfig
|
|
109
209
|
raise Puppet::Error, "Unsupported translation file format #{file_format}; please use :po or :mo"
|
110
210
|
end
|
111
211
|
|
112
|
-
|
113
|
-
raise Puppet::Error, "A project name must be specified in order to initialize translations."
|
114
|
-
end
|
115
|
-
|
116
|
-
add_repository_to_domain(project_name, locale_dir, file_format)
|
212
|
+
add_repository_to_domain(project_name, locale_dir, file_format, text_domain)
|
117
213
|
return true
|
118
214
|
end
|
119
215
|
|
120
216
|
# @api private
|
121
217
|
# Add the translations for this project to the domain's repository chain
|
122
218
|
# chain for the currently selected text domain, if needed.
|
123
|
-
# @param
|
124
|
-
# @param
|
125
|
-
# @param
|
126
|
-
def self.add_repository_to_domain(project_name, locale_dir, file_format)
|
127
|
-
|
128
|
-
|
129
|
-
|
219
|
+
# @param [String] project_name the name of the project for which to load translations
|
220
|
+
# @param [String] locale_dir the path to the directory containing translations
|
221
|
+
# @param [Symbol] file_format the fomat of the translations files, :po or :mo
|
222
|
+
def self.add_repository_to_domain(project_name, locale_dir, file_format, text_domain = FastGettext.text_domain)
|
223
|
+
return if @gettext_disabled || !gettext_loaded?
|
224
|
+
|
225
|
+
current_chain = FastGettext.translation_repositories[text_domain].chain
|
130
226
|
|
131
227
|
repository = FastGettext::TranslationRepository.build(project_name,
|
132
228
|
path: locale_dir,
|
133
229
|
type: file_format,
|
134
|
-
|
135
|
-
@loaded_repositories[project_name] = true
|
230
|
+
report_warning: false)
|
136
231
|
current_chain << repository
|
137
232
|
end
|
138
233
|
|
234
|
+
# @api private
|
235
|
+
# Sets FastGettext's locale to the current system locale
|
236
|
+
def self.setup_locale
|
237
|
+
return if @gettext_disabled || !gettext_loaded?
|
238
|
+
|
239
|
+
set_locale(Locale.current.language)
|
240
|
+
end
|
241
|
+
|
139
242
|
# @api private
|
140
243
|
# Sets the language in which to display strings.
|
141
|
-
# @param
|
244
|
+
# @param [String] locale the language portion of a locale string (e.g. "ja")
|
142
245
|
def self.set_locale(locale)
|
143
|
-
return if !gettext_loaded?
|
246
|
+
return if @gettext_disabled || !gettext_loaded?
|
144
247
|
# make sure we're not using the `available_locales` machinery
|
145
248
|
FastGettext.default_available_locales = nil
|
146
249
|
|