Class: RemLint::Rules::LocalizationPack

Inherits:
RemLint::Rule show all
Defined in:
lib/remlint/rules/localization_pack.rb

Overview

A language pack that never translates LANGID.

Scripts branch on _("LANGID") to pick language-specific behaviour, and an untranslated LANGID reverts to "en". So a fully translated pack that never translates LANGID sends every one of those scripts down the English path -- and does it by producing English, which reads as "not translated yet" rather than "translated and ignored".

A pack is recognised by its day and month names, which is what include/lang/*.rem set and what nothing else does. A file translating a handful of strings -- include/translations/de/sun.rem is two lines -- is not a pack and has no LANGID to translate.

Constant Summary collapse

LANGID =
"LANGID"
PACK_NAMES =

What a language pack sets and a string file does not.

(
  %w[monday tuesday wednesday thursday friday saturday sunday] +
  %w[january february march april may june july
     august september october november december
]
).freeze
TRANSLATED =
/\A\s*"(?<original>(?:[^"\\]|\\.)*)"\s*"/
SYSVAR_SET =
/\A\$(?<name>\w+)\s/

Constants inherited from RemLint::Rule

RemLint::Rule::REGISTRY

Instance Attribute Summary

Attributes inherited from RemLint::Rule

#config, #document, #offenses

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from RemLint::Rule

all, enabled_by_default?, find, inherited, #initialize, rule_name, #rule_name, #run

Constructor Details

This class inherits a constructor from RemLint::Rule

Class Method Details

.default_severityObject



34
35
36
# File 'lib/remlint/rules/localization_pack.rb', line 34

def self.default_severity
  "info"
end

.descriptionObject



38
39
40
# File 'lib/remlint/rules/localization_pack.rb', line 38

def self.description
  "A language pack that never translates LANGID, which reverts to English."
end

Instance Method Details

#checkObject



42
43
44
45
46
# File 'lib/remlint/rules/localization_pack.rb', line 42

def check
  if pack?
    check_langid
  end
end