Skip to content

Conversation

@Hakan-Soysal
Copy link

Added Turkish character mappings to the slugify function to handle Turkish characters properly.

Summary

Updated the slugify function to provide robust support for Turkish localization. This change introduces a character mapping layer that transforms Turkish-specific characters (like ğ, ş, ı) into their ASCII equivalents before the regex cleanup. It also ensures that the " & " symbol is semantically preserved as "-and-" instead of being stripped out.

Checklist

  • Documented steps to test (below)
  • Drafted “how to use” docs (if this adds new behavior)
  • Backwards compatibility considered (notes if applicable)

Documented steps to test

  1. Test Turkish Mapping: Call slugify("Eskişehir & İstanbul").

Expected Result: "eskisehir-and-istanbul"

  1. Test Semantic Preservation: Call slugify("Bread & Butter").

Expected Result: "bread-and-butter"

  1. Test Casing and Symbols: Call slugify("Ilık Bir Gün @2024!").

Expected Result: "ilik-bir-gun-2024" (Ensures the dotless 'I' maps to 'i' and non-alphanumerics are cleaned).

  1. Test Edge Trimming: Call slugify("---test---").

Expected Result: "test"

Notes for reviewers

  1. Character Map: Uses a Record<string, string> to explicitly handle ı/İ, ş/Ş, ğ/Ğ, ü/Ü, ö/Ö, and ç/Ç.
  2. Pipeline Order: * Maps Turkish characters first.
    • Converts to lowercase.
    • Converts & to -and-.
    • Strips remaining non-alphanumeric characters.
    • Trims leading/trailing hyphens.

Added Turkish character mappings to the slugify function to handle Turkish characters properly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant