1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2025-07-21 19:32:57 +00:00

Comments: Put @ on the right side of right-to-left usernames

From the discussion in
https://github.com/TeamNewPipe/NewPipe/pull/12188 it reads more
natural for RTL readers.
This commit is contained in:
Profpatsch 2025-05-07 14:20:44 +02:00
parent 862a8e8f26
commit e554c77f2e

View File

@ -90,19 +90,14 @@ public final class Localization {
* Localize a user name like <code>@foobar</code>.
*
* Will correctly handle right-to-left usernames by using a {@link BidiFormatter}.
* For right-to-left usernames, it will put the @ on the right side to read more naturally.
*
* @param plainName username, with an optional leading <code>@</code>
* @return a usernames that can include RTL-characters
*/
@NonNull
public static String localizeUserName(final String plainName) {
final BidiFormatter bidi = BidiFormatter.getInstance();
if (plainName.startsWith("@")) {
return "@" + bidi.unicodeWrap(plainName.substring(1));
} else {
return bidi.unicodeWrap(plainName);
}
return BidiFormatter.getInstance().unicodeWrap(plainName);
}
public static org.schabi.newpipe.extractor.localization.Localization getPreferredLocalization(