pixelfed icon indicating copy to clipboard operation
pixelfed copied to clipboard

feat: translate

Open eufelipemateus opened this issue 7 months ago β€’ 2 comments

πŸ“Œ PR Description

This PR adds support for translating the profile bio and post captions in PixelFed, using Google Translate and DeepL as translation providers.


πŸ“· Screenshots

Captura de tela de 2025-05-23 20-47-46 Captura de tela de 2025-05-23 20-47-57 Captura de tela de 2025-05-23 20-00-49 Captura de tela de 2025-05-23 19-51-13

βš™οΈ Implementation Details

  • Supports two translation providers:

    • google β†’ requires the GOOGLE_API_KEY environment variable
    • deepl β†’ requires the DEEPL_API_KEY environment variable
  • The feature is controlled by the following settings:

    • pixelfed.translation.enabled = true enables the feature system-wide
    • pixelfed.translation.users_limited = true restricts the feature to selected users

πŸ”§ To-Do

  • Complete the admin panel UI to allow configuration through the dashboard
  • ~~Implement translation button visibility control when:~~
    • ~~pixelfed.translation.enabled = false~~
    • ~~The feature is disabled for the user~~
  • ~~Define a reliable way to hide the translate button when the feature is turned off~~

βœ… Status

  • [x] Functional translation for bio and captions
  • [x] Integration with Google and DeepL providers
  • [x] Reads from environment variables
  • [ ] Admin interface pending
  • [x] Button visibility logic not yet implemented

πŸ“ Notes

The translation feature is currently functional but not yet finalized. Admin configuration and ~~conditional button visibility~~ still need to be completed for a polished user experience.

eufelipemateus avatar May 24 '25 00:05 eufelipemateus

Any plans to add support for LibreTranslate? That's something you can selfhost.

https://libretranslate.com

https://github.com/LibreTranslate/LibreTranslate

Leatherface75 avatar Jun 10 '25 12:06 Leatherface75

Any plans to add support for LibreTranslate? That's something you can selfhost.

https://libretranslate.com

https://github.com/LibreTranslate/LibreTranslate

This is quite easy to implement, something like that.

image

image

i can make commit without test.

eufelipemateus avatar Jun 10 '25 13:06 eufelipemateus

Any plans to add support for LibreTranslate? That's something you can selfhost. https://libretranslate.com https://github.com/LibreTranslate/LibreTranslate

This is quite easy to implement, something like that.

image

image

i can make commit without test.

That would be good i can test it if it works.

Leatherface75 avatar Jun 24 '25 16:06 Leatherface75

Any plans to add support for LibreTranslate? That's something you can selfhost. https://libretranslate.com https://github.com/LibreTranslate/LibreTranslate

This is quite easy to implement, something like that. image image i can make commit without test.

That would be good i can test it if it works.

already implment

eufelipemateus avatar Jul 19 '25 18:07 eufelipemateus

Any plans to add support for LibreTranslate? That's something you can selfhost. https://libretranslate.com https://github.com/LibreTranslate/LibreTranslate

This is quite easy to implement, something like that. image image i can make commit without test.

That would be good i can test it if it works.

already implment

I tried it but it doesnt show translate option. Didn't work with Google Translate either so i am probably doing something wrong.

Leatherface75 avatar Jul 20 '25 13:07 Leatherface75

Any plans to add support for LibreTranslate? That's something you can selfhost. https://libretranslate.com https://github.com/LibreTranslate/LibreTranslate

This is quite easy to implement, something like that. image image i can make commit without test.

That would be good i can test it if it works.

already implment

I tried it but it doesnt show translate option. Didn't work with Google Translate either so i am probably doing something wrong.

It could be a cache issue. Here, the translation option also takes a little while to appear because of configuration caching, especially if you're using Redis.

First, in your .env file, enable the feature by setting TRANSLATION_ENABLED to true. Then, clear the cache using the commands php artisan config:clear and php artisan cache:clear.

After that, refresh the page and check if the translation button appears.

If you're using Google Translate, set TRANSLATION_PROVIDER to google in your .env file and add your API key using the GOOGLE_API_KEY variable.

If you want to use LibreTranslate instead, set TRANSLATION_PROVIDER to libre, add your API key with LIBRE_API_KEY, and provide the API URL with LIBRE_API_URL (for example, https://libretranslate.de).

Also, don’t forget to clear your browser cache after doing all that. Once everything is in place, the translation button should show up and work correctly.

eufelipemateus avatar Jul 20 '25 23:07 eufelipemateus