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

Unexpected truncation in languages that do not use word divider #281

Closed
wakairo opened this issue Dec 22, 2023 · 2 comments · Fixed by #283
Closed

Unexpected truncation in languages that do not use word divider #281

wakairo opened this issue Dec 22, 2023 · 2 comments · Fixed by #283

Comments

@wakairo
Copy link
Contributor

wakairo commented Dec 22, 2023

Problem

In Japanese, which do not use word divider, meta-tags can truncate title, description, etc. at unexpected position and can make them too short.

Because Japanese is a language that do not use word divider, basically there is no space character in Japanese text.
But sometimes a proper noun from a foreign language is directly used in Japanese, and in this case there can be space character in the proper noun even in Japanese text.

Here is an example. The following Japanese text has a space only at the 10th character, which is in the middle of "Microsoft Copilot".

Microsoft Copilotは、あなたの言葉をパワフルなコンテンツに変える AI アシスタントです。あなたのニーズに合わせて、文章を生成、要約、編集、変換したり、コードや詩などの創造的なコンテンツを作成したりします。

meta-tags truncates at the space. Therefore, if a Japanese text has spaces only near the beginning, it will be truncated near the beginning.

For example, even if the setting is to truncate to 80 characters, the Japanese text mentioned above will be truncated at the 10th character and the result become “Microsoft”, which is much shorter than 80 characters.

Request

I think README.md should mention that meta-tags truncates at the space and the issue mentioned above can occur.

How truncation at a space character occurs in meta-tags

meta-tags internally calls the truncate helper method of Ruby on Rails, and it has a method that wraps this helper method.
The third argument of this wrapper method is natural_separator and this argument can be omitted.
Actually there exists a call of the method with omission. The default value under this omission is a space character, so the truncation occurs at the space.

@kpumuk
Copy link
Owner

kpumuk commented Dec 26, 2023

Hello. I have introduced a configuration option in #283, would that work for you?

@wakairo
Copy link
Contributor Author

wakairo commented Dec 29, 2023

Yes, it works for me! Thank you for this enhancement!
Because there seems no explanation about truncate_on_natural_separator for users in the repository, I have made PR #286. If it helps, please merge it.
Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants