From e939d0e1f51baaa5d8f229f54bc18d3cc438d71b Mon Sep 17 00:00:00 2001 From: David Wessman Date: Sat, 21 Oct 2023 17:53:05 +0200 Subject: [PATCH] PatternScanner: Handles non \w characters - Fixes #526 --- lib/i18n/tasks/scanners/pattern_scanner.rb | 2 +- spec/used_keys_spec.rb | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/i18n/tasks/scanners/pattern_scanner.rb b/lib/i18n/tasks/scanners/pattern_scanner.rb index 0779d4a5..080f75e4 100644 --- a/lib/i18n/tasks/scanners/pattern_scanner.rb +++ b/lib/i18n/tasks/scanners/pattern_scanner.rb @@ -12,7 +12,7 @@ class PatternScanner < FileScanner include OccurrenceFromPosition include RubyKeyLiterals - TRANSLATE_CALL_RE = /(?<=^|[^\w'\-.]|[^\w'-]I18n\.|I18n\.)t(?:!|ranslate!?)?/.freeze + TRANSLATE_CALL_RE = /(?<=^|[^\p{L}'\-.]|[^\p{L}'-]I18n\.|I18n\.)t(?:!|ranslate!?)?/.freeze IGNORE_LINES = { 'coffee' => /^\s*#(?!\si18n-tasks-use)/, 'erb' => /^\s*<%\s*#(?!\si18n-tasks-use)/, diff --git a/spec/used_keys_spec.rb b/spec/used_keys_spec.rb index ac6e834b..e0e0dc82 100644 --- a/spec/used_keys_spec.rb +++ b/spec/used_keys_spec.rb @@ -12,6 +12,9 @@ h1 = t 'b' h2 = t 'c.layer' h3 = t 'c.layer.underneath_c' + // Do not match non \w characters before the t + // https://github.com/glebm/i18n-tasks/issues/526 + | À bientôt ! SLIM end