FIX: Generate ASCII slug with default locale

FIX: Generate ASCII slug with default locale

diff --git a/lib/slug.rb b/lib/slug.rb
index 669006c..27ded2a 100644
--- a/lib/slug.rb
+++ b/lib/slug.rb
@@ -36,7 +36,9 @@ module Slug
   end
 
   def self.ascii_generator(string)
-    string.tr("'", "").parameterize
+    I18n.with_locale(SiteSetting.default_locale) do
+      string.tr("'", "").parameterize
+    end
   end
 
   def self.encoded_generator(string, downcase: true)
diff --git a/spec/components/slug_spec.rb b/spec/components/slug_spec.rb
index 991ff23..99ba5a2 100644
--- a/spec/components/slug_spec.rb
+++ b/spec/components/slug_spec.rb
@@ -46,6 +46,12 @@ describe Slug do
       it "fallbacks to empty string if it's too long" do
         expect(Slug.for(very_long_string)).to eq(default_slug)
       end
+
+      it "transliterates with the default locale" do
+        SiteSetting.default_locale = :de
+        I18n.locale = :en
+        expect(Slug.for('löwe')).to eq('loewe')
+      end
     end
 
     context 'encoded generator' do

GitHub sha: 56f60653

1 Like

This commit has been mentioned on Discourse Meta. There might be relevant details there: