HelloZeroNet / Documentation

ZeroNet Documentation
https://zeronet.readthedocs.org/
GNU General Public License v2.0
74 stars 107 forks source link

[ WIP ] Support multi-language doc #117

Closed rllola closed 5 years ago

rllola commented 5 years ago

See https://github.com/HelloZeroNet/Documentation/issues/113

anoadragon453 commented 5 years ago

Good start! Does the search field still work correctly after being moved?

rllola commented 5 years ago

Good start! Does the search field still work correctly after being moved?

Weirdly it does not. I didn't expect it to be affected by the new icon. I am gonna fix it.

EDIT: False alarm. My bad. I tested without the server running...

rllola commented 5 years ago

Update button with the dropdown menu.

screenshot from 2018-11-22 06-55-56 screenshot from 2018-11-22 06-56-32

anoadragon453 commented 5 years ago

Looks good. Have you tested this on mobile layout yet by the way?

rllola commented 5 years ago

Looks good. Have you tested this on mobile layout yet by the way?

Yes. The layout is modified on mobile so a special css will be needed unfortunately. I will try to finish for next week.

anoadragon453 commented 5 years ago

Ok, looking forward to seeing it!

rllola commented 5 years ago

@anoadragon453 Do you know how the doc is being deployed ? Do you do a mkdocs build and serve the files through apache or something ?

rllola commented 5 years ago

French translation + Translation HowTo button.

screenshot from 2018-11-23 07-25-51

anoadragon453 commented 5 years ago

@rllola This is indeed what I do.

Looking good :)

rllola commented 5 years ago

@rllola This is indeed what I do.

Could you share the config file with me ? Or is it ok if I put in an Nginx docker container ?

I see two things which need to be done in the config for it to work :

And we should be good.

EDIT: Actually, I might misunderstood how the site is generated and we might event do better... :smirk: Will come with more about that tomorrow.

rllola commented 5 years ago

Ok I have made it. See the Nginx file with the 2 needed rules. Not sure how to translate it into Apache...

I still need to customize the generate.py because some folders has to move. But we are on the good path. I am pretty happy with it.

I removed the mobile compatibility from the list for this PR. I will do it in another one. This one already start to be heavy.

rllola commented 5 years ago

Done !

This is ready for review !

HelloZeroNet commented 5 years ago

thanks for the PR, here is a test deployment: https://zeronet.io/docs-dev/

Some things I noticed:

rllola commented 5 years ago

I believe that using the same icon is better. Consistency is good in general. I have done 3 screenshots of what it look like with different variants. Let me know which one you prefer. screenshot from 2018-11-27 09-06-22 screenshot from 2018-11-27 09-07-35 screenshot from 2018-11-27 09-08-15

anoadragon453 commented 5 years ago

I definitely prefer the first one as it indicates action can be made, along with the current language it is set to.

rllola commented 5 years ago

I agree this is also my favorite. I modified the code to this one.

HelloZeroNet commented 5 years ago

Thanks, I have updated the source: https://zeronet.io/docs-dev/

Looks good to me, the only problem is with the search that is uses index from english docs and the links points to /en/ page

rllola commented 5 years ago

@HelloZeroNet Look like you have a rule that automatically redirect toward english. It forbid me to get the correct french file with this rule :

  # NEEDED !
  location /search/ {
    # Try to know the current language in order to send the proper serch_index.json file
    if ($http_referer ~ /fr/) {
      rewrite (.*) /fr/$1;
    }

    if ($http_referer ~ /en/) {
      rewrite (.*) /en/$1;
    }
  }

screenshot from 2018-11-29 04-53-04 screenshot from 2018-11-29 04-53-31

Could you show me your apache config file ?

HelloZeroNet commented 5 years ago

Actually I using apache, so I created separate rules and if it's possible I would not trust the referrer as it's not avaliable in every browser. Do you think if there is other way to do it?

rllola commented 5 years ago

Ok. No problem.

The search_index.json is loaded in application.js (https://github.com/squidfunk/mkdocs-material/blob/master/src/assets/javascripts/application.js#L290) which is part of the mkdocs-material sources. I don't think we can override it in theme like I did for the header.

The referer part was a bit hacky but the other solution would be a PR in mkdocs-material project.

However I am not sure what exactly ${config.url.base}/$ does... I am going to investigate otherwise I think we can do a PR to avoid the referrer hack.

rllola commented 5 years ago

@HelloZeroNet

mxfzvni

I was actually able to override the javascript file and add it to the base.html theme file. It append the language suffix. Still hacky but better than the nginx rules I think.

HelloZeroNet commented 5 years ago

I was hoping it's easier to fix it, I have updated the source: https://zeronet.io/docs-dev/en/

There is some assets that is missing, because it's got accessed from /docs-dev/en/ dir

rllola commented 5 years ago

Some files are being redirected... Any reason that would be happening ?

screenshot from 2018-11-30 14-57-18

The assets files should be outside of the /en directory.

screenshot from 2018-11-30 15-02-52

EDIT: Or are those path redirected because they are missing ?

rllola commented 5 years ago

I have commited the generated site. You could directly serve it.

HelloZeroNet commented 5 years ago

It redirects all non-existent files to /en/ directory

It tries to load "modernizr.20ef595d.js", but in that directory it puts "modernizr.1aa3b519.js"

It works with the generated site, but I think it would be better not putting it to the repository and if the generated site is broken for me, then it's probably will be broken for others

rllola commented 5 years ago

Maybe you don't have the same version of mkdocs-material as me ? I have 3.1.0

$ pip list
mkdocs                        1.0.4    
mkdocs-material               3.1.0   

It look like he released a new version just before I start to work on this and it shipped differents files with it.

HelloZeroNet commented 5 years ago

Yeah, different version here:

$ pip list | grep mkdocs
mkdocs (1.0.4)
mkdocs-material (3.0.4)

I can update to 3.1.0, but this means that probably it won't work with the future versions.

rllola commented 5 years ago

We just need to be all using the same version and be careful when a new one is out to update base.html but it should work without problem.

If we freeze the dependencies in a requirements.txt file it should be fine.

HelloZeroNet commented 5 years ago

A took a step back and went using a different approach that does not requires modification of the base template or extra web server rules:

Then built using mkdocs build -f mkdocs.yml and mkdocs build -f mkdocs-fr.yml

This way the en docs is at https://zeronet.io/docs/, the fr is at https://zeronet.io/docs/fr and the search is working. The img, js, css resources are duplicated, but I think this is the best solution we have now.

The lang changer menu is still missing can you please open a new PR for it?

rllola commented 5 years ago

It does work and I agree it avoid changing the base.html. However it does break the language menu.

Before that I would just replace whatever language code is in the url but now I would need to know the prefix path to it...

EDIT: I am actually not sure it is the best solution. As it does make it a little bit more complicated for the menu language to work. However I am fine with whatever solution works. Also I override the headers.html too so it might broke in the future too. Only if something with headers.html has been modfied tho and it is written in the documentation that you can override those so it will probably not happen actually...