Repository: LemmyNet/lemmy (language: rust)

Issue:
Allow admin to choose any additional languages to be selected for newly registered users in addition to "Undetermined" and "English"
### Requirements

- [X] Is this a feature request? For questions or discussions use https://lemmy.ml/c/lemmy_support
- [X] Did you check to see if this issue already exists?
- [X] Is this only a feature request? Do not put multiple feature requests in one issue.
- [X] Is this a backend issue? Use the [lemmy-ui](https://github.com/LemmyNet/lemmy-ui) repo for UI / frontend issues.
- [X] Do you agree to follow the rules in our [Code of Conduct](https://join-lemmy.org/docs/code_of_conduct.html)?

### Is your proposal related to a problem?

I am running an instance for a specific country (Georgia) where people's browsers do not always carry the language information (a lot of people use English as their system/browser language). 

This means that when a new user signs up, their profile settings are set to "Undetermined" and "English" only so everything (which is literally everything) posted in language "ქართული" is not displayed. and it is very inconvenient to explain to the user to go to their settings and press Ctrl and look for "ქართული" and then posts will be displayed. 



### Describe the solution you'd like.

Allow admins from the admin panel to select languages that should be selected for every newly registered user.

I guess it should be very simple to do this. As it was explained to me:
"The default languages for creating a new user are taken from all the languages in your browser's Accept-Language header, then we add UNDETERMINED to it."

So maybe add a list of languages to admin panel that should also be added for a new user regisration.

### Describe alternatives you've considered.

Other way is to modify the code and maintain my own branch. I want to follow the official branch and not break upgrades. 

### Additional context

_No response_


Discussion / hints:
Lemmy currently uses the user's browser language as default, which may not be English.
This still creates issues, as most users will want to have English enabled at least as additional language, as a lot of content on is not tagged correctly.
For now, we've put a link to [a post](https://feddit.org/post/163939) in the sidebar where people can go look if they're missing comments.
It should add *all* the user's browser languages, but yes I agree it'd be nice to be able to add a set of default languages besides undetermined for new users.
ah, i think i confused it with the interface language when i looked for it.
I made a change in https://github.com/LemmyNet/lemmy/pull/5235 so that new users also have the site languages which are configured under `/admin`. This way it has the same effect without an extra setting.

Fix patch:
diff --git a/.woodpecker.yml b/.woodpecker.yml
index 68241bdde4..8f69ae367a 100644
--- a/.woodpecker.yml
+++ b/.woodpecker.yml
@@ -4,11 +4,12 @@
 variables:
   - &rust_image "rust:1.80"
   - &rust_nightly_image "rustlang/rust:nightly"
-  - &install_pnpm "corepack enable pnpm"
+  - &install_pnpm "npm install -g corepack@latest && corepack enable pnpm"
   - &install_binstall "wget -O- https://github.com/cargo-bins/cargo-binstall/releases/latest/download/cargo-binstall-x86_64-unknown-linux-musl.tgz | tar -xvz -C /usr/local/cargo/bin"
   - install_diesel_cli: &install_diesel_cli
       - apt-get update && apt-get install -y postgresql-client
-      - cargo install diesel_cli --no-default-features --features postgres
+      # --locked ensures compatibility with the currently used rust version
+      - cargo install diesel_cli --no-default-features --features postgres --locked
       - export PATH="$CARGO_HOME/bin:$PATH"
   - &slow_check_paths
     - event: pull_request
diff --git a/crates/api_crud/src/user/create.rs b/crates/api_crud/src/user/create.rs
index 64bef8760e..15a004dfcf 100644
--- a/crates/api_crud/src/user/create.rs
+++ b/crates/api_crud/src/user/create.rs
@@ -19,6 +19,7 @@ use lemmy_api_common::{
 use lemmy_db_schema::{
   aggregates::structs::PersonAggregates,
   source::{
+    actor_language::SiteLanguage,
     captcha_answer::{CaptchaAnswer, CheckCaptchaAnswer},
     language::Language,
     local_user::{LocalUser, LocalUserInsertForm},
@@ -166,11 +167,18 @@ pub async fn register(
   let all_languages = Language::read_all(&mut context.pool()).await?;
   // use hashset to avoid duplicates
   let mut language_ids = HashSet::new();
+
+  // Enable languages from `Accept-Language` header
   for l in language_tags {
     if let Some(found) = all_languages.iter().find(|all| all.code == l) {
       language_ids.insert(found.id);
     }
   }
+
+  // Enable site languages. Ignored if all languages are enabled.
+  let discussion_languages = SiteLanguage::read(&mut context.pool(), local_site.site_id).await?;
+  language_ids.extend(discussion_languages);
+
   let language_ids = language_ids.into_iter().collect();
 
   let inserted_local_user =


Test patch:
diff --git a/api_tests/src/user.spec.ts b/api_tests/src/user.spec.ts
index 2edcf54ea8..0cc747d2b0 100644
--- a/api_tests/src/user.spec.ts
+++ b/api_tests/src/user.spec.ts
@@ -23,7 +23,12 @@ import {
   unfollows,
   saveUserSettingsBio,
 } from "./shared";
-import { LemmyHttp, SaveUserSettings, UploadImage } from "lemmy-js-client";
+import {
+  EditSite,
+  LemmyHttp,
+  SaveUserSettings,
+  UploadImage,
+} from "lemmy-js-client";
 import { GetPosts } from "lemmy-js-client/dist/types/GetPosts";
 
 beforeAll(setupLogins);
@@ -149,9 +154,14 @@ test("Create user with Arabic name", async () => {
 });
 
 test("Create user with accept-language", async () => {
+  const edit: EditSite = {
+    discussion_languages: [32],
+  };
+  await alpha.editSite(edit);
+
   let lemmy_http = new LemmyHttp(alphaUrl, {
     // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Language#syntax
-    headers: { "Accept-Language": "fr-CH, en;q=0.8, de;q=0.7, *;q=0.5" },
+    headers: { "Accept-Language": "fr-CH, en;q=0.8, *;q=0.5" },
   });
   let user = await registerUser(lemmy_http, alphaUrl);