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

Prepare for using Weblate #2611

Merged
merged 8 commits into from
Jan 24, 2023
Merged

Prepare for using Weblate #2611

merged 8 commits into from
Jan 24, 2023

Conversation

401U
Copy link
Contributor

@401U 401U commented Jan 15, 2023

  • I have read and understand the pull request rules.

Description

As mentioned in #1591 , we decided to try weblate as translation platform.
I have converted the translation file to json format, and it works with vue-i18n.

Following tasks:

  • Set up translation workflow on Weblate
  • Edit docs to refuse further translation pr (should use weblate then)
  • Clean up the code, remove previous js translation file, and my convert script, etc

close #1034
close #1873

Type of change

  • Translation update
  • This change requires a documentation update

Checklist

  • My code follows the style guidelines of this project
  • I ran ESLint and other linters for modified files
  • I have performed a self-review of my own code and tested it
  • I have commented my code, particularly in hard-to-understand areas
    (including JSDoc for methods)
  • My changes generate no new warnings
  • My code needed automated testing. I have added them (this is optional task)

@401U
Copy link
Contributor Author

401U commented Jan 15, 2023

To setup in weblate, you should give me some permission( Here is me).
I'll try to setup a demo project with my branch to avoid potential side effects.

@louislam
Copy link
Owner

To setup in weblate, you should give me some permission( Here is me). I'll try to setup a demo project with my branch to avoid potential side effects.

I checked this option, see if it is ok.

image

@401U
Copy link
Contributor Author

401U commented Jan 15, 2023

I checked this option, see if it is ok.

It seems ok, will try to setup a demo project later.

@401U
Copy link
Contributor Author

401U commented Jan 16, 2023

I need your help to continue.
My demo project stuck here with no log.
image

I have tested my project/compone settings with weblate docker container on my laptop, which will log the process of updating component, then success to load languages.
image

I have checked the settings of weblate.kuma.pet to locate the problem, only find out that Celery is not configured. Maybe that's the reason.
Also you can check the log to get detailed error message.

@louislam
Copy link
Owner

How to config Celery?

Here is the docker-compose

version: '3.8'
services:
  weblate:
    image: weblate/weblate
    tmpfs:
    - /app/cache
    volumes:
    - weblate-data:/app/data
    restart: always
    depends_on:
    - database
    - cache
    deploy:
      placement:
        constraints: [node.hostname == panel6]
    environment:
    - WEBLATE_SITE_DOMAIN=weblate.kuma.pet
    - WEBLATE_DEBUG=1
    - WEBLATE_LOGLEVEL=DEBUG
    - WEBLATE_SITE_TITLE=Uptime Kuma Weblate
    - WEBLATE_ADMIN_NAME=Louis Lam
    - WEBLATE_ADMIN_EMAIL=<MASKED>
    - WEBLATE_ADMIN_PASSWORD=<MASKED>
    - WEBLATE_SERVER_EMAIL=<MASKED>
    - WEBLATE_DEFAULT_FROM_EMAIL=<MASKED>
    - WEBLATE_ALLOWED_HOSTS=*
    - WEBLATE_REGISTRATION_OPEN=1
    - WEBLATE_EMAIL_HOST=127.0.0.1
    - WEBLATE_SOCIAL_AUTH_GITHUB_KEY=<MASKED>
    - WEBLATE_SOCIAL_AUTH_GITHUB_SECRET=<MASKED>
    - WEBLATE_SOCIAL_AUTH_GITHUB_SCOPE = ["user:email"]
    - WEBLATE_ENABLE_HTTPS=1

    - WEBLATE_REGISTRATION_ALLOW_BACKENDS = ["github"]
    - POSTGRES_PASSWORD=<MASKED>
    - POSTGRES_USER=<MASKED>
    - POSTGRES_DATABASE=weblate
    - POSTGRES_HOST=database
    - POSTGRES_PORT=
    - REDIS_HOST=cache
    - REDIS_PORT=6379
  database:
    image: postgres:14-alpine
    environment:
    - POSTGRES_PASSWORD=<MASKED>
    - POSTGRES_USER=<MASKED>
    - POSTGRES_DATABASE=weblate
    - POSTGRES_HOST=database
    - POSTGRES_PORT=
    volumes:
    - postgres-data:/var/lib/postgresql/data
    restart: always
    deploy:
      placement:
        constraints: [node.hostname == <MASKED>]
  cache:
    image: redis:6-alpine
    restart: always
    command: [redis-server, --save, '60', '1']
    deploy:
      placement:
        constraints: [node.hostname == <MASKED>]
    volumes:
    - redis-data:/data
    environment:
    - REDIS_HOST=cache
    - REDIS_PORT=6379
  cloudflared-tunnel:
    image: cloudflare/cloudflared
    restart: always
    deploy:
      placement:
        constraints: [node.hostname == <MASKED>]
    command: tunnel run
    environment:
    - TUNNEL_TOKEN=<MASKED>
volumes:
  weblate-data: {}
  postgres-data: {}
  redis-data: {}

@401U
Copy link
Contributor Author

401U commented Jan 16, 2023

My config:
docker-compose.yml

version: '3'
services:
  weblate:
    image: weblate/weblate
    tmpfs:
    - /app/cache
    volumes:
    - weblate-data:/app/data
    env_file:
    - ./environment
    restart: always
    depends_on:
    - database
    - cache
  database:
    image: postgres:15-alpine
    env_file:
    - ./environment
    volumes:
    - postgres-data:/var/lib/postgresql/data
    restart: always
  cache:
    image: redis:7-alpine
    restart: always
    command: [redis-server, --save, '60', '1']
    volumes:
    - redis-data:/data
volumes:
  weblate-data: {}
  postgres-data: {}
  redis-data: {}

docker-compose.override.yml

version: '3'
services:
  weblate:
    ports:
      - 80:8080
    environment:
      WEBLATE_SITE_DOMAIN: weblate.example.com
      WEBLATE_ADMIN_PASSWORD: password
      WEBLATE_ADMIN_EMAIL: admin@4o1.to

Performance page shows that celery is not running.
No idea why Celery works with my config, as there is no line in my config that contains Celery. I will have a try with your config.

Edit: missing file of my config:
environment

# See Weblate documentation for detailed description:
# https://docs.weblate.org/en/latest/admin/deployments.html#docker

# Weblate setup
WEBLATE_DEBUG=0
WEBLATE_LOGLEVEL=INFO
WEBLATE_SITE_TITLE=Weblate
WEBLATE_ADMIN_NAME=Weblate Admin
WEBLATE_ADMIN_EMAIL=weblate@example.com
WEBLATE_ADMIN_PASSWORD=
WEBLATE_SERVER_EMAIL=weblate@example.com
WEBLATE_DEFAULT_FROM_EMAIL=weblate@example.com
WEBLATE_ALLOWED_HOSTS=*
WEBLATE_REGISTRATION_OPEN=1

# Extra
#WEBLATE_TIME_ZONE=
#WEBLATE_MT_GOOGLE_KEY=
#WEBLATE_MT_GOOGLE_CREDENTIALS=
#WEBLATE_MT_GOOGLE_PROJECT=
#WEBLATE_MT_GOOGLE_LOCATION=
#WEBLATE_SOCIAL_AUTH_GITHUB_KEY=
#WEBLATE_SOCIAL_AUTH_GITHUB_SECRET=
#WEBLATE_SOCIAL_AUTH_BITBUCKET_KEY=
#WEBLATE_SOCIAL_AUTH_BITBUCKET_SECRET=
#WEBLATE_SOCIAL_AUTH_FACEBOOK_KEY=
#WEBLATE_SOCIAL_AUTH_FACEBOOK_SECRET=
#WEBLATE_SOCIAL_AUTH_GOOGLE_OAUTH2_KEY=
#WEBLATE_SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET=

#WEBLATE_OFFLOAD_INDEXING=1
#WEBLATE_GOOGLE_ANALYTICS_ID=
#WEBLATE_ENABLE_HTTPS=1
#WEBLATE_IP_PROXY_HEADER=HTTP_X_FORWARDED_FOR
#WEBLATE_REQUIRE_LOGIN=1

# LDAP Auth
#WEBLATE_AUTH_LDAP_SERVER_URI=ldap://ldap.example.org
#WEBLATE_AUTH_LDAP_USER_DN_TEMPLATE=uid=%(user)s,ou=People,dc=example,dc=net
#WEBLATE_AUTH_LDAP_USER_ATTR_MAP=first_name:name,email:mail

# PostgreSQL setup
POSTGRES_PASSWORD=weblate
POSTGRES_USER=weblate
POSTGRES_DATABASE=weblate
POSTGRES_HOST=database
POSTGRES_PORT=

# Cache setup
# https://docs.weblate.org/en/latest/admin/install.html#production-cache
REDIS_HOST=cache
REDIS_PORT=6379

# Mail server, the server has to listen on port 587 and understand TLS
WEBLATE_EMAIL_HOST=127.0.0.1
# Do NOT use quotes here
WEBLATE_EMAIL_HOST_USER=
# Do NOT use quotes here
WEBLATE_EMAIL_HOST_PASSWORD=

# GitLab lab setup
# WEBLATE_GITLAB_USERNAME=
# WEBLATE_GITLAB_HOST=
# WEBLATE_GITLAB_TOKEN=

Actually these files are cloned from https://github.com/WeblateOrg/docker-compose

@401U
Copy link
Contributor Author

401U commented Jan 16, 2023

Seems noting wrong with your docker-compose.yml, it works on my laptop(just remove github related environments and cloudflare-tunnel service). Celery could start up, and no stuck when adding component.
Just restart or try to destroy old containers?

@louislam
Copy link
Owner

Seems ok now, after I set WEBLATE_DEBUG to 0

@401U
Copy link
Contributor Author

401U commented Jan 16, 2023

Yes, it works now. And push from weblate to github also works. See here
Currently, translation changes would directly push to github at configured interval. For this push method, you should add its ssh key in github with write permssion (repo settings -> depoly keys), and use SSH url for push.
SSH key:

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDBH7ZOiUmwH0SMOma5DEm9xaFCGg2m4CJJ/uicANp3uVx+wWrPfdvX/dmDV3t89GPKolVpC+b+sDelkXWHcOs7WV2BTMHwe5pUKszSFedBD4NtzFJ98jT4wR8LC3DeB8gp58mlpCzPEhDoWqcFgbqLb6O6XL9k3yMHWupDv/RqWTaI3ce7sQsSN+1ur5oYy3JViiKpHsHiVqKjKCNEiRsAMRARuS+uFEj6dgsyFGFWaYnloCbOhSDkvwquwbyBU214+fGSSzBxiCS2pG5NdOZ2OtDcvZGgJdxa4ZWc2Rz2mOPf4ts7uEkLaWvdQgFqcAaQhC7sPkmqyIHkvZwkog8poDJPmBSzsjFBdJk38TbwPxo8Hu4RSIIPi8jUXJzXEBaOVs2SW5BtJgt1q1zKnBwKqVkq6xKAgEzpYKf2Lh38PgZZ2GH4a5C00XZUNdM/44lpeh85H0aqVt2dN4Xx/uN4KdNLO1ZUWcBS79kfR1n7AH158pByMuP0ryWyCZlUnwHBaGV/WC58fvBsS8f7KnBn3+rMp80zhOxfA3f8FUQF3WeEUBTUU8yTaGHEkFCzlVguiLDkv6t5/xnLiKvSI8M5Ya4kv/wN5HM4LQaIM5/8FeniyHiGr+vvSuaqFdhvUWHYF9fxc7tYqUNf7SEisSvC+KzyTCCplBA8vXbFsq1z7w== Uptime Kuma Weblate

Weblate also support create pull request on github, but need config GITHUB-USERNAME GITHUB_TOKEN
All available push method here
I'll setup project with no push method first Merge required for that, and please let me know what push method you want to use.

@401U
Copy link
Contributor Author

401U commented Jan 16, 2023

Also, to automatically receiving changes from GitHub, webhook is required.

Settings about continuous

@401U
Copy link
Contributor Author

401U commented Jan 16, 2023

I think we need a merge to push things forword, as json file is required in this repo to continue. Docs update and code clean up can be done in another pr.
Or should I just do these commits here?

@louislam louislam added this to the 1.20.0 milestone Jan 16, 2023
@louislam
Copy link
Owner

It will be the highest priority pr in 1.20.0. But I am now focusing on 1.19.5 first.

@louislam
Copy link
Owner

louislam commented Jan 19, 2023

Other contributors have submitted new language pull requests, should I merge them first?

#2634 #2638

@401U
Copy link
Contributor Author

401U commented Jan 20, 2023

You can merge them, and I 'll update my pr later.
Current translation workflow is allowed until you decide to focus on this pr.

@louislam
Copy link
Owner

Yes, it works now. And push from weblate to github also works. See here Currently, translation changes would directly push to github at configured interval. For this push method, you should add its ssh key in github with write permssion (repo settings -> depoly keys), and use SSH url for push. SSH key:

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDBH7ZOiUmwH0SMOma5DEm9xaFCGg2m4CJJ/uicANp3uVx+wWrPfdvX/dmDV3t89GPKolVpC+b+sDelkXWHcOs7WV2BTMHwe5pUKszSFedBD4NtzFJ98jT4wR8LC3DeB8gp58mlpCzPEhDoWqcFgbqLb6O6XL9k3yMHWupDv/RqWTaI3ce7sQsSN+1ur5oYy3JViiKpHsHiVqKjKCNEiRsAMRARuS+uFEj6dgsyFGFWaYnloCbOhSDkvwquwbyBU214+fGSSzBxiCS2pG5NdOZ2OtDcvZGgJdxa4ZWc2Rz2mOPf4ts7uEkLaWvdQgFqcAaQhC7sPkmqyIHkvZwkog8poDJPmBSzsjFBdJk38TbwPxo8Hu4RSIIPi8jUXJzXEBaOVs2SW5BtJgt1q1zKnBwKqVkq6xKAgEzpYKf2Lh38PgZZ2GH4a5C00XZUNdM/44lpeh85H0aqVt2dN4Xx/uN4KdNLO1ZUWcBS79kfR1n7AH158pByMuP0ryWyCZlUnwHBaGV/WC58fvBsS8f7KnBn3+rMp80zhOxfA3f8FUQF3WeEUBTUU8yTaGHEkFCzlVguiLDkv6t5/xnLiKvSI8M5Ya4kv/wN5HM4LQaIM5/8FeniyHiGr+vvSuaqFdhvUWHYF9fxc7tYqUNf7SEisSvC+KzyTCCplBA8vXbFsq1z7w== Uptime Kuma Weblate

Weblate also support create pull request on github, but need config GITHUB-USERNAME GITHUB_TOKEN All available push method here I'll setup project with no push method first Merge required for that, and please let me know what push method you want to use.

I would like to use the pull request method.

@louislam
Copy link
Owner

Also have set up GITHUB_USERNAME, GITHUB_TOKEN. I will merge it once #2634 #2638 are merged.

@401U
Copy link
Contributor Author

401U commented Jan 21, 2023

Also have set up GITHUB_USERNAME, GITHUB_TOKEN.

Sorry to bother you again, but I can't see Github in version control system selections, which is required for pr push method, and should apper after set up GITHUB_USERNAME and GITHUB_TOKEN.

I checked the documents again, and figured out that using GITHUB_USERNAME and GITHUB_TOKEN is deprecated since version 4.14.2. Now they recommand to use GITHUB_CREDENTIALS.

Anyway, it's my fault that I didn't read their documents carefully.

I will merge it once #2634 #2638 are merged.

After you merge them, I will commit to sync their language file changes. you can wait a bit before merge my pr.

@louislam
Copy link
Owner

I have added GITHUB_CREDENTIALS, but the GitHub option is still not available in the list. I double checked that it should be already set inside the container. Do you have any idea?

docker-compose.yml
image

Inside the container:
image

Plain text:

    - |
      GITHUB_CREDENTIALS = {
        "api.github.com": {
          "username": "louislam",
          "token": "gh<MASKED>F9"
        }
      }

@401U
Copy link
Contributor Author

401U commented Jan 24, 2023

I have added GITHUB_CREDENTIALS, but the GitHub option is still not available in the list. I double checked that it should be already set inside the container. Do you have any idea?

No idea about that, can't see github option on my local deployment either, I will try to locate the problem.

@401U
Copy link
Contributor Author

401U commented Jan 24, 2023

After dive into weblate code, I figured out that its docker image use WEBLATE_GITHUB_USERNAME and WEBLATE_GITHUB_TOKEN, and the Github option would appear.

https://github.com/WeblateOrg/weblate/blob/main/weblate/settings_docker.py#L212-L214
https://github.com/WeblateOrg/weblate/blob/main/weblate/utils/environment.py#L63-L73

edit: checked their docs again, they have mentioned it, but not so obvious. https://docs.weblate.org/en/latest/admin/install/docker.html#docker-environment-variables

@louislam
Copy link
Owner

Lol, it is so confusing. Thank you for your help.
That's why I always don't like environment variables as settings.

I see the GitHub option now.

@401U
Copy link
Contributor Author

401U commented Jan 24, 2023

Ok, It works! 401U#1

@louislam
Copy link
Owner

Ok, It works! YehowahLiu#1

Want to test one more thing, try to use weblate as the GITHUB_USERNAME

@401U
Copy link
Contributor Author

401U commented Jan 24, 2023

Want to test one more thing, try to use weblate as the GITHUB_USERNAME

It won't work, as it should match the github token.
ref: WeblateOrg/weblate#6765

@louislam
Copy link
Owner

Want to test one more thing, try to use weblate as the GITHUB_USERNAME

It won't work, as it should match the github token. ref: WeblateOrg/weblate#6765

Oh, maybe I open a new github account for that.

@louislam louislam merged commit b05c620 into louislam:master Jan 24, 2023
@401U
Copy link
Contributor Author

401U commented Jan 24, 2023

Oh, maybe I open a new github account for that.

With a new github account, you should add the ssh key of weblate platform to it's ssh keys (https://github.com/settings/keys), and the pr would be open from fork.
Otherwise, we need a new branch for dirct push, and add ssh key to depoly key with write permission, and pr would be open from that branch.

A webhook to fetch github changes is required, url is https://weblate.kuma.pet/hooks/github.

I'll start without push method firstly.

@louislam
Copy link
Owner

I cannot add it. It said Key is already in use.

@401U
Copy link
Contributor Author

401U commented Jan 24, 2023

Deleted from my repo deploy key, you can try again. Or consider create a new one on weblate.

@louislam
Copy link
Owner

Ok now, added.

@401U
Copy link
Contributor Author

401U commented Jan 24, 2023

Focus on #2662

@louislam louislam mentioned this pull request Jan 25, 2023
7 tasks
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.

javascript language file to json for translate correctly to es, fr and it Easier translation process
2 participants