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

Adding documentation and updating .po #255

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
113 changes: 113 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,116 @@ Guide](http://docs.geoserver.org/latest/en/docguide/style.html)
- [Sphinx reStructuredText
Primer](http://www.sphinx-doc.org/rest.html)

## Setting up the translation/dev enviroment

Below we detail the two options according to your operating system:

### Requirements
1. python3
2. pip3

<br><br>
### Linux or Mac

The steps are:

1. Create a virtual environment `python3 -m venv geonode-documentation`

2. Activate the environment

```
source geonode-documentation/bin/activate
```

3. Install requirements:

```
pip3 install -r requirements_docs.txt
```

4. To generate the html build:

```
make html
```

To especify language:
```
./build.sh <language>
```

for example in spanish:
```
./build.sh es
```



### Windows

1. Create a virtual environment called 'geonode-documentation' in your local directory. Then, activate it:

```
.\virtual_env.bat
```

2. Activate the environment:

```
.\geonode-docs\Scripts\activate.bat
```

3. With 'activated' virtualenv. Install the requirements via pip:

```
pip install -r requirements_docs.txt
```

4. Run the build from within that venv, using the make.bat script with the html argument to locally build the docs:

```
make.bat html
```

5. Then, in your local directory look for: \geonode-documentation\_build\html\index.html

<br></br>

## Update translations
To update the current translations, use `make Makefile gettext`
## Configure transiflex library to make your own translations
To configure your own transifex, you will need to install the last library specified in the file requirements_docs.txt (transifex-client) and create your own .tx/config file
<br></br>
### Create your own config file

1. It is needed to delete (or move) the original .tx/config file in order to point the translations to your own transifex project
- `rm .tx/config` or `mv .tx/config .tx/config_bkp`

2. Initialize transifex
- With a transifex account already created, search for your API Token and run `export TX_TOKEN=<your_Transifex_API_token>`
- `tx init`
You will se something like this
```
Welcome to the Transifex Client! Please follow the instructions to
initialize your project.

Creating .tx folder...
Creating config file...
No credentials file was found at transifexrc.
Created .transifexrc
Enter your API token: <your_Tranisfex_API_token>
Verifying token...
Updating .transifexrc file...
```
### Push elements to translate

3. Now it is needed to map the .po files in order to push the translations to our transifex
- There is a script that do that for us. So we will need to execute edit the file `create_transifex_resources.sh` in order to add our project name in the PROJECT variable
- Once it is added. Proceed to run it. `bash create_transifex_resources.sh`
4. Now with all sections mapped. We can push all the messages to our transifex
- Execute `tx push -f -s -t --no-interactive --skip`
5. Once finished, the platform is ready to accept new translations in new languajes.
### Translate
6. Now you will be able to star translating.
7. When finished, you can take the changes executing `tx pull -a` and build again the help with the new lenguajes and translations
- `bash build.sh <languaje>`
67 changes: 67 additions & 0 deletions create_transifex_resources.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/bin/bash

# This script is used to register QGIS-Documentation translatable resources with Transifex
# https://www.transifex.com
#
# Note that this script updates or creates entries in .tx/config file
# so that they match expected formatting of tx-github integration slugs.
# Used to first "tx push" existing translations to Transifex when enabling the github integration
#
# Tim Sutton, March 2013
# Update: Harrissou Sant-anna, December 2020

TARGETBRANCH=`git branch --show-current`
SOURCEPOFILES='locale/en/LC_MESSAGES/'
PROJECT=<INSERT YOUR TRANSIFEX PROJECT NAME>
CONFIGFILE='.tx/config'

# To be sure there are no *.pot or *.mo files left
make springclean

# Regenerate the English PO files
make gettext
# Only rm if really starting from scratch (might "break" metadata in transifex)
# rm -r $SOURCEPOFILES
sphinx-intl update -p build/gettext -l en

# Clean generated translation *.po files from obsolete strings, if any
find $SOURCEPOFILES -type f -name '*.po' -exec sed -i '/^#~ /,/^$/d' {} \;

# Clean the .tx/config files from existing references, out of the main section
# each reference is made of 5 lines and a blank line
sed -i "/$PROJECT/,+5d" .tx/config

for POFILE in `find $SOURCEPOFILES -type f -name '*.po'`
do
#echo $POFILE
# get the po file, replacing 'en' with '<lang>' and removing double '//'s in path
GENERICFILE=`echo $POFILE | sed 's,\/en\/,\/<lang>\/,g' | sed 's,\/\/,\/,g'`
echo $GENERICFILE

# Set the resource slug by
# lowering the case of the whole text
# appending the target branch name after double "-"
# and replacing "_", "/", ".", "\" and " " characters with "-" in the path
# so for a file like
# locale/en/LC_MESSAGES/docs/user_manual/processing/3rdParty.po in release_3.16 branch
# we will get
# locale-en-lc-messages-docs-user-manual-processing-3rdparty-po--release-3-16
RESOURCE=`echo "$POFILE--$TARGETBRANCH" | tr '[:upper:]' '[:lower:]' | sed 's,[_/ \.\\],-,g'`
echo $RESOURCE

# Populate the config file
# When we are done in this block we should have created sections in the
# .tx/config file that look like this:
#
# [qgis-documentation.locale-en-lc-messages-docs-user-manual-processing-3rdparty-po--release-3-16]
# file_filter = locale/<lang>/LC_MESSAGES/docs/user_manual/processing/3rdParty.po
# source_file = locale/en/LC_MESSAGES/docs/user_manual/processing/3rdParty.po
# source_lang = en
# type = PO
#
echo -e "[$PROJECT.$RESOURCE]\nfile_filter = $GENERICFILE\nsource_file = $POFILE\nsource_lang = en\ntype = PO\n" >> $CONFIGFILE

done

# Print out a listing of all registered resources
#tx status
Binary file modified locale/en/LC_MESSAGES/about/index.mo
Binary file not shown.