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

NIP-37: Language Tag #632

Closed
wants to merge 1 commit into from
Closed

Conversation

alexgleason
Copy link
Member

Adds a lang tag for text events allowing users to specify their language.

NIP text here: https://github.com/alexgleason/nips/blob/dcb38b6e2301e149a2d592d1880bd3a6a7492f03/37.md

@fiatjaf
Copy link
Member

fiatjaf commented Jul 2, 2023

I think users can't be trusted to specify this tag correctly and all automatic translation tools will already detect the language automatically anyway.

@alexgleason
Copy link
Member Author

alexgleason commented Jul 2, 2023

I basically just copied what Mastodon does since I'm implementing some equivalent features. But I figured automatic detection would be the main counterpoint to this.

I think it would still be cool if relays indexed events by their language and let you filter them.

@staab
Copy link
Member

staab commented Jul 2, 2023

I would suggest using NIP 32 for this use case. That would have the benefit of using single letter tags so language would be searchable, and allowing people to both mark their own notes and those of others (for example you could build a bot that publishes 1985 events based on language detection).

@alexgleason
Copy link
Member Author

NIP-32 actually seems like it wants a lang tag to exist. Because then you could label an event like ["l", "en", "#lang"]

I'm not sure it makes more semantic sense to add ["l", "en", "ISO-639-1"] to a note, than just ["lang", "en"]

@vitorpamplona
Copy link
Collaborator

vitorpamplona commented Jul 8, 2023

I don't think there is a reliable way to implement this. On Amethyst, we could get the system language, the keyboard language or try to process it with the translator before signing. However, they are all faulty solutions. Users don't generally switch keyboards to write in other languages and the in-device language identifier is not that accurate for Nostr posts (short bursts of grammatically imprecise text with tons of "weirdness" like URLs, hashtags, and bech addresses). We could ask the user to specify in the new post screen, but it might be just annoying for the average user.

On the flipside, I think this could go into a longer discussion on content tagging/rating by third parties. The same NIP that can allow an agency to mark events as PG-13 content, can also be used to specify the language and other attributes of the post. Users would then follow their preferred agency to get the type of content they like to see.

@alexgleason
Copy link
Member Author

The cool thing to do would be for relays to just automatically detect the language with fasttext, and then respond to queries for a particular language.

@vitorpamplona This MR is about letting the user set the language manually the way Mastodon does it:

image

I have mixed feelings about it. I'm creating a compatibility layer with Mastodon. At first I'm going to use this "lang" tag to decide whether to display a "translate post" button to the user. But a better solution will likely evolve.

@arthurfranca
Copy link
Contributor

The cool thing to do would be for relays to just automatically detect the language with fasttext, and then respond to queries for a particular language.

Relays can use that, other libs or also check NIP-32 labels if available to decide what is the language. #605 (NIP-17 Event Metadata) PR is exactly for this. Recently added here a way to filter by language.

@alexgleason
Copy link
Member Author

I am using a tag like this for the language:

["l", "en", "ISO-639-1"]

@alexgleason alexgleason closed this Jun 7, 2024
@alopatindev
Copy link
Contributor

alopatindev commented Jul 24, 2024

I found various issues about language labeling and I'm still confused: do we have any standard way to specify language for event kind 1 right now?

I am using a tag like this for the language:
["l", "en", "ISO-639-1"]

Am I right that NIP-32 currently allows

{
  "kind": 1,
  "tags": [
    ["L", "ISO-639-1"],
    ["l", "en", "ISO-639-1"]
  ],
  "content": "English text",
  ...
}

but it's not that we've decided that it's best way to do that (because some suggest en-US, etc.)? Can we have this example in NIP-32?

I'd like to post in multiple languages from single account and give my followers possibility to filter out messages in languages they don't understand; ideally disallow them with mute list. Maybe even give them "Follow my English posts" and "Follow all my posts" buttons in a relevant page of a multilingual website. Does the NIP-51 mute list support the l tags?

@alexgleason
Copy link
Member Author

Yes your event looks fine. Yes we should have the example in NIP-32.

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.

6 participants