I've added the possibility to translate the html error page, replacing a token with the current language prefix.
It only work for websites using the language prefix.
Feel free to improve this with a query to get the domains, and handle the language by domain.
How it works ?
$conf['fast_404_HTML_error_page'] = './404/index_##LANG##.html';
The ##LANG##
token will be replaced by the current language prefix.
You can have index_.html, index_en.html, index_it.html, etc.
Comment | File | Size | Author |
---|---|---|---|
#40 | interdiff-38.txt | 2.41 KB | seanB |
#39 | 2370323-38-10.0.patch | 11.9 KB | seanB |
| |||
#38 | 2370323-38.patch | 10.89 KB | seanB |
#36 | interdiff_31-36.txt | 723 bytes | mrinalini9 |
#36 | 2370323_36.patch | 11.19 KB | mrinalini9 |
Comments
Comment #1
cutesquirrel CreditAttribution: cutesquirrel commentedComment #2
adammaloneThe only way I could see this working with early stage bootstrap is if the path was parsed and determined to contain a language or if languages were found from the database (We already query the locale table). My concern about this is how we would know which language was desired, I'm not confident about replacing tokens.
This patch also introduces whitespace and shouldn't introduce another global.
Comment #3
alexander.sibert CreditAttribution: alexander.sibert commentedGreat module and i'm also interest on this feature. I use on a current project i18n with lang codes.
Comment #4
gappleHere's a patch that checks if the requested path is prefixed with a valid language.
Comment #6
gappleHere's an updated patch for latest dev
Comment #7
gappleI ran into a weird issue on Acquia hosting where the Database API functions were available when
fast_404_path_check()
was called in settings.php.This caused problems with my patches, because the variables are not bootstrapped yet, and
drupal_multilingual()
then always returns false.I fixed this by using the check for the locale module's status, as was originally used in
fast_404_validate_path_drupal()
, instead ofdrupal_multilingual()
.Comment #8
eddie_c CreditAttribution: eddie_c at Oxfam International commentedIt would be great to have this feature in the 8.x-1.x branch. It may be simpler to achieve in the D8 version by parsing the language prefix from the path in
Fast404->response()
and then using that to load a language appropriate static HTML file in a way similar to the one suggested here by @cutesquirrelPerhaps this should be worked on for Drupal 8 first and then backported to D7 in order to make sure this feature isn't abandoned going forward?
Optimistically bumping the version of this issue up to 8.x!
Comment #9
gg4 CreditAttribution: gg4 commentedComment #10
YahyaAlHamadAdded the ability to translate in version 2, I'm not sure if this is the best way. Read the
example.settings.fast404.php
for more info.Comment #12
YahyaAlHamadFixed the test, also, added a new test, to test 'fast404_HTML_error_page' functionality.
Comment #13
YahyaAlHamadI used the LanguageManager service to determine the current language, I fear that I have missed the whole point of the module.
Comment #14
Kristen PolThanks for the issue, patches, and reviews!
I took a quick look and have some minor feedback, mostly nitpicks. Moving back to needs work for at least fixing the typos.
* Typo: "mananger" => "manager".
* Nitpick: Add period.
Nitpick: This goes beyond 80 characters. Perhaps reword slightly, e.g.
The langcode to use for the translated 404 page if it exists.
* Nitpick: This goes beyond 80 characters.
* Nitpick: These should be 2 separate sentences or be separated by a ";" instead of a comma.
Nitpick: Move else to own line, e.g.
Nitpick: Add space after
if
.* Nitpick: Should these use spaces instead of tabs?
* Nitpick: Change "Custom Page not found" to "Custom Page Not Found".
Nitpick: Add period.
Typo: "existant" => "existent".
Nitpick: Change "Custom Page not found" to "Custom Page Not Found".
Typo: "existant" => "existent".
Nitpick: Change "Custom Page not found" to "Custom Page Not Found".
Typo: "existant" => "existent".
Comment #15
Kristen PolLooks like the approach changed, so the issue summary will need updating.
Comment #16
Kristen PolAdding novice tag as changes to patch are simple.
Comment #17
srilakshmier CreditAttribution: srilakshmier at Valuebound for Valuebound commentedUploading the patch based on the feedback in #14.
Please review.
Thank you
Comment #18
Kristen PolThanks for the update. I reviewed the interdiff. Not sure why the tests were removed so moving back to needs work for adding those back and I noticed a couple minor things as well.
Update to wrap comment at <80 characters.
Extra space after the
}
.Shouldn't be removed.
Shouldn't be removed.
Shouldn't be removed.
Most of the feedback from #14 was not addressed.
Comment #19
elberComment #20
elberMy patch has the changes mentioned in the comment #18, and I didn't exclude the HTML files.
Comment #21
Kristen PolThank you for your attempt at helping @elber but this is still using the bad patch from #17 which is missing tests. This is noted in #18 but I guess I didn't make that obvious enough so...
Whoever works on this next:
1. PLEASE USE PATCH FROM #12.
2. Then look at the feedback from #14 and #18.
3. Do an interdiff between #12 and your updated patch. (The patches in #17 and #20 broke things like removing tests.)
Thanks.
Comment #22
elberComment #23
elberI'm still working on this!
Comment #24
elberComment #25
Kristen PolLooked at the interdiff and see the test files being removed. Also, make sure there are no extra spaces at the end of lines.
Back to needs work.
Why are you removing test files?
Why are you removing test files?
Why are you removing test files?
Comment #26
elberComment #27
joshua1234511Updated the path from #12
Worked on feedback from #14
#13 no specific feedback to be worked on just as #14 was not addressed.
Additional Addresed
FILE: /fast_404/tests/src/Functional/Fast404HtmlPageTest.php
-------------------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
-------------------------------------------------------------------------------------------------------------------------
79 | ERROR | [x] Expected 1 blank line after function; 0 found
80 | ERROR | [x] The closing brace for the class must have an empty line before it
Comment #28
Kristen PolThanks @joshua1234511!
We should add some explicit testing steps so people can try this.
This still needs code review too.
Comment #29
Kristen PolThanks for updating the patch and cleaning up the code formatting issues. I reviewed again and there are a couple things:
Comments shouldn't read like code, so this should be reworded to something like:
For arrays, use the path associated with the langcode or the first path if the langcode is not set.
1. The indentation here does not follow indentation seen in other
html
files in core, e.g.core/modules/color/preview.html
.2. Nitpick: Should
Custom Page Not Found
be wrapped inon one line? e.g.
Same as above.
Comment #30
lucasbaralmComment #31
lucasbaralmFixing standards and comments mentioned in #29.
Comment #32
lucasbaralmComment #33
diegorsComment #34
diegors@lucasbaralm has fixed standards mentioned in comment #29.
Comment #35
Kristen PolSome minor formatting issues remain:
There's some whitespace and wrapping issues here.
1. "first" can move a line up
2. need space after "//"
3. do not have extraneous spaces at end of lines
4. empty line not needed
Comment #36
mrinalini9 CreditAttribution: mrinalini9 at Material for Drupal India Association commentedUpdated patch #31 by addressing #35, please review it.
Thanks!
Comment #37
joseph.olstadComment #38
seanBReroll for 3.x.
Comment #39
seanBFixed coding standards and made the patch compatible with 10.x (the method signature for
BrowserTestBase::setUp()
changed).Comment #40
seanBYay! Tests are green. Here is the interdiff for the latest 9.x and 10.x patches of #38 / #39.
Comment #41
YahyaAlHamadComment #42
akashpj CreditAttribution: akashpj as a volunteer and at Cognizant Technology Solutions for Drupal India Association commentedTested #39 patch in drupal 9.5.x and 10.1.x
patch applied successfully and working as expected
Verified the changes suggested in #35 - Changes are addressed.