Vexatos / RTFM

A Markdown-Based Custom Manual
Other
3 stars 2 forks source link

On first open, default index ignores configured path #3

Closed leagris closed 7 years ago

leagris commented 7 years ago

When first opening manual, no Tab is selected and, path in rtfm.cfg is ignored. It then tries to load a static default path %LANGUAGE%/index.md that is not part of configuration for general section.

If %LANGUAGE% relative path does not exists; it can not find the index. It happens only when first opening the documentation after login-in, because no Tab has been selected. Once user selects a Tab, proper paths are those configured for selected Tab.

# Default: '%LANGUAGE%/index.md'. The path to the manual page that will open when the tab is clicked.
# '%LANGUAGE%' will be replaced with the currently selected language, for instance 'en_US'
S:tabPath=en_US/index.md

Incentive to not use %LANGUAGE% in path is: to have a consistent default documentation available and working, even if user selected Language is not en_US, like en_GB or fr_FR.

I suggest you could add an option for a fall-back locale name like this:

manual {
  # Locale to fall-back to if '%LANGUAGE%' path does not exists, as user may have
  # configured a different language than available for tab document path.
  S:fallbackLocale=en_US
Vexatos commented 7 years ago

%LANGUAGE% will always fall back to en_us if the page is not found in the currently selected language.

leagris commented 7 years ago

@Vexatos I had issue with en_usen_US on Linux/MacOS Systems. It look like paths in config are not affected by lowercased resource names. A Fall-back language en_us you changed in commit, will not find files in en_US directory with Linux/MacOS systems. And an en_US locale will not find files stored in en_us

Vexatos commented 7 years ago

The locale is always called en_us since Minecraft 1.11. There is no en_US anymore.

leagris commented 7 years ago

@Vexatos

Config file paths are not lowercased in 1.11.2. the locale environment variable returns en_US mixed casing, because this is what is configured in options.txt

lang:en_US

So, I think you may be wrong here:

We had %LANGUAGE%/index.mdnot loaded on linux because file path was config/rtfm/en_us/changelogs/index.md https://github.com/Beyond-Reality/Beyond-Realty-Farscapes/blob/8977626f922a16b1aff4f4c20dc95f42fba07347/config/rtfm/en_us/changelogs/index.md

as configured in https://github.com/Beyond-Reality/Beyond-Realty-Farscapes/blob/8977626f922a16b1aff4f4c20dc95f42fba07347/config/rtfm.cfg#L43-L49

    changelogs {

        S:tabIcon=minecraft:paper@0
        I:tabIconMode=1
        S:tabName=tooltip.rtfm.manual.tab2
        S:tabPath=%LANGUAGE%/changelogs/index.md
}

When concatenating this locale to file path, it searched here for: config/rtfm/en_US/changelogs/index.md (because lang:en_US inoptions.txt)

whereas the dir name was: config/rtfm/en_us/changelogs/index.md

So, if you set:

private static final String FALLBACK_LANGUAGE = "en_us";

On one side, users with lang:en_US will have files searched in config/rtfm/en_US

Whereas users with lang:en_GB into options.txt with FALLBACK_LANGUAGE = "en_us" will have files searched in config/rtfm/en_us

This will break on OS differentiating path/file casing.

leagris commented 7 years ago

So, to avoid confusion and issues with OS path casing, and be safe when MC/Forges decides to lowercase config files as well. Just lowercase the Language string. It will work everywhere and with future implementations.

Vexatos commented 7 years ago

I am not quite sure what your issue is. I am using Linux myself and everything works exactly as expected, no matter which language I select. options.txt should definitely not have lang:en_US but lang:en_us, and it does for me. Not sure what you are doing wrong.

leagris commented 7 years ago

Dear, go get a break before re-reading :)

Your commit did not address initial issue:

But you broke it with https://github.com/Vexatos/RTFM/commit/d5b81ec3c151e388eec2a2d05a8f679e963e88c7 because now, users on fall-back will not access same files paths.

Vexatos commented 7 years ago

You claim it isn't working, but I cannot reproduce that. It works for me every single test regardless of the language I select. Changing mainTab to change the page it opens on first use works too.