Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to prevent auto translation for my arabic tags #304

Closed
abdelkareemkobo opened this issue Dec 2, 2023 · 7 comments
Closed

how to prevent auto translation for my arabic tags #304

abdelkareemkobo opened this issue Dec 2, 2023 · 7 comments

Comments

@abdelkareemkobo
Copy link

I have configured an astrowind template for my blog but when i write an Arabic article the tag go from "الدمام" into aldmam!
who to solve this problem!

@abdelkareemkobo
Copy link
Author

image

@prototypa
Copy link
Contributor

prototypa commented Dec 3, 2023

Hi @abdelkareemkobo

The problem you describe is because the tag name and slug are not saved for the tags, the slug is simply used to show the tags everywhere (including the url).

To create the slug we use a dependency that does those conversions: limax. We have come up with some ideas to solve it but we still do not have a definitive solution to the problem. Maybe if we add a new optional Content Collection so that in cases like yours you can define the name of the tag and slug, we will tell you later what we can think of or if you have any suggestions please let us know.

For now we will give you the two lines that are associated with it:

@abdelkareemkobo
Copy link
Author

@prototypa thanks for the fast response, I am waiting for the solution!!

@abdelkareemkobo
Copy link
Author

@prototypa can you read this issue where they solve it but i don't know what should i change now in my astrowind theme!
issue
it's a really quick one, thanks in advance

@abdelkareemkobo
Copy link
Author

@prototypa Is there any update for this problem! i have built the website and host it but just can't solve this problem! and it prevents me from building the other website with this cool theme!

@abdelkareemkobo
Copy link
Author

@prototypa here is my solution

export const cleanSlug = (text = '') => {
  const regex = /[^\d\u0621-\u064A]+/g;

  return trimSlash(text)
    .split('/')
    .map((slug, index, array) => {
      // Preserve slashes in the middle, but replace in the beginning and end
      if (index !== 0 && index !== array.length - 1) {
        return slug;
      }

      // If the slug starts with "-", consider it as a tag and preserve it
      if (slug.startsWith('-')) {
        return slug;
      }

      // Otherwise, replace unwanted characters
      return slug.replace(regex, '-');
    })
    .join('/');
};

I don't know if it the right way to solve it but i works!
the only thing that is wrong is with the
image
is the /-/ should be the word "tag"

@prototypa
Copy link
Contributor

Hi @abdelkareemkobo

Sorry for the delay.

Another thing you can do is go to this line:

const tags = rawTags.map((tag: string) => cleanSlug(tag));

and instead of using cleanSlug, create a new function cleanTagSlug that cleans up the slug for the tags a bit, (for example, replaces the spaces with '-' or whatever you need). In simpler case remove the call to the cleanSlug function

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

No branches or pull requests

2 participants