Use browsers language settings to set language (rlmp_language_detection) - typo3

I try to automaticly set the language in my typo3 6.2 One-Tree Page.
To my setup, I use RealURL to add the langauge to the URL, I use the default Lparameter. I DON'T use ISO codes for the languages, but I use static_info_tables to set the ISO Code. For the language switch I try to use the extention rlmp_language_detection but it does not work.
My language config (typo3name, Official ISO Code - selected with static_info_tables, ID - used for Lparameter)
default, -, 0
en-jp, en, 1
en-us, en, 2
jp-jp, ja, 3
My Typoscript for the plugin:
plugin.tx_rlmplanguagedetection_pi1 {
useOneTreeMethod = 1
defaultLang = en
}
My Typoscript for langauges:
config {
sys_language_uid = 0
language = en
locale_all = en-eu
}
[globalVar = GP:L = 1]
config {
sys_language_uid = 1
language = en
locale_all = en-us
}
[global]
[globalVar = GP:L = 2]
config {
sys_language_uid = 2
language = en
locale_all = en-jp
}
[global]
[globalVar = GP:L = 3]
config {
sys_language_uid = 3
language = jp
locale_all = jp-jp
}
[global]
To test it I set my first langauge to japanese and when I request the rootpage this is in my request-header:
Accept-Language:ja,de-DE;q=0.8,de;q=0.6,en-US;q=0.4,en;q=0.2
http://mybrowserinfo.com/ say:
Language:Japanese
System Language:Not detectable with this browser
User Language:de
But no L Parameter is set at all, so I get the default language.

I've had same problems:
How i made it works step by step:
1 Step:
install static_info_tables be careful it should be in DB utf-8 charsetin latin1 (in my case) don't work
2 Step:
istall rlmp_language_detection
3 Step:
check if on you server installed php-geoip php module, if not install Ext: ml_geoip or any way install it.
4 Step
include static templates in your TS template
5 Step
Pls don't forget to choose ISO code of toy lang in base line pages tree
6 Step
TS settings - add this after all lang configuration
plugin.tx_rlmplanguagedetection_pi1 {
# this mean that you hav ejust one tree pages for all lang, for multi trees look manual
useOneTreeMethod = 1
#important - this your website sys_language default
defaultLang = ru
# use -1 when you wont to test redirect, after change to 0
cookieLifetime = -1
# you defind which method will be used for redirect browser or ip, better testing just with one
testOrder = browser,ip
# we can config aliases like "code = lang1, lang2"
languageAliases >
languageAliases {
ua = uk,en
en = en
ru = ru,en
}
#we can country codes dependencies "country code = lang"
countryCodeToLanguageCode >
countryCodeToLanguageCode {
ua = uk
us = en
gb = en
nz = en
au = en
ie = en
ca = en
by = ru
}
#this just limit input params array
limitToLanguages = ru,uk,en
}
# ok just after all we include ext to page, on ts begining you shoud to have "page = PAGE" just check
page.1007 = < plugin.tx_rlmplanguagedetection_pi1

I'd suggest using .htaccess to redirect the browser acceptance language. This saves you loading up the whole TYPO3 instance just to do a redirect.
Depending on weather you use realurl it would look something like this:
RewriteCond %{HTTP:Accept-Language} ^en-us [NC]
RewriteRule ^$ /en-us/ [L,R=307]
RewriteCond %{HTTP:Accept-Language} ^ja [NC]
RewriteRule ^$ /jp/ [L,R=307]
RewriteCond %{HTTP:Accept-Language} ^en-gb [NC]
RewriteRule ^$ /en-eu/ [L,R=307]
I don't know how to target en-jp though.
On our websites we use the 307 as status code, so the browser will always look for the initial page (in case the structure changes), also it doesn't affect SEO.

Related

TYPO3 9.5 LTS - configuration for custom PAGE type with routeEnhancers

I have a vCard-solution that worked fine with TYPO3 version 8 and realURL but doesn't work with TYPO3 9.5.
vCard is triggered with an URL like:
mywebsite.de/de/vcard.html?staffid=123&type=5000
Configuration:
1) staffid=123 loads the values of staff member with ID 123 into the vCard:
[globalVar = GP:staffid=123]
VCARD_name = vcard-schneider-martin.vcf
N_name = N:Schneider;Martin;;;Martin Schneider
[...]
[global]
2) in order to load the special PAGE type the TypoScript is:
vCard = PAGE
vCard {
typeNum = 5000
config {
disableAllHeaderCode = 1
additionalHeaders = Content-Type:text/x-vcard|Content-Disposition: attachment; filename="{$VCARD_name}"
[...]
}
}
How does the routeEnhancers (of config.yaml) has to be configured in order to make TYPO3 9.5 starting the vCard PAGE object with typeNum=5000 and render the vCard for the team member with the current value of GP variable "staffid" (from the URL)?
Thanks!
I use this configuration for sitemap.xml with pageType 1533906435 and backslash für pageType 0 (section map of my config):
routeEnhancers:
PageTypeSuffix:
type: PageType
default: /
index: ''
map:
/: 0
sitemap.xml: 1533906435
see also:
https://usetypo3.com/xml-sitemap-in-typo3.html

TYPO3 Exception thrown but not shown in FE/BE

How can I show Exception in Debug Mode (Install -> Presets) in FE?
I'm using LTS 7.6.29
My TYPO3 configuration is
1 BE/debug
1 FE/debug
* SYS/devIPmask
1 SYS/displayErrors
file SYS/enableDeprecationLog
1 SYS/sqlDebug
0 SYS/systemLogLevel
1 SYS/clearCacheSystem
config.contentObjectExceptionHandler = 0
PHP.ini
error_reporting = E_ALL
display_errors = On
display_startup_errors = On
log_errors = On
You've to use this setting in TypoScript to show Error-Messages in Frontend:
config {
contentObjectExceptionHandler = 0
}
In the file LocalConfiguration.php you've to set following values, it's explained how to set them by using the installtool:
SYS
Try, to disable the TYPO3 exception handlers in general:
System > Install > "All Configuration"
Filter by (search-field): exceptionhandler
Set empty values:
[SYS][productionExceptionHandler] =
[SYS][debugExceptionHandler] =
[SYS][errorHandler] =
After debugging set exception handling to the default values:
[SYS][productionExceptionHandler] =
TYPO3\CMS\Core\Error\ProductionExceptionHandler
[SYS][debugExceptionHandler] = TYPO3\CMS\Core\Error\DebugExceptionHandler
[SYS][errorHandler] = TYPO3\CMS\Core\Error\ErrorHandler
After changing the settings you've to delete the file typo3temp/autoload/autoload_classmap.php that the changed settings are applied to the system. The file will be new created but with a bit different content.
You can delete the file too in installtool by deleting the autoload-information.
Most is explained here: https://docs.typo3.org/typo3cms/extensions/launch/Administrators/03_Errorhandling/09_OopsAnErrorOccured/Index.html

need link to documentation on how to 'MASK' website content while creating a TYPO3 template as a extension

I am trying to create a template which can be reused in TYPO3. I want to offer it as a free extension for the community. Currently I am following the standards specified in youtube video series https://www.youtube.com/watch?v=HtBmim7pc0o and https://www.sitepackagebuilder.com/ ) and https://github.com/benjaminkott/bootstrap_package.
I need to 'MASK' the template but cannot get access to relevant Tutorials. Can anybody help me out?
Thanks in advance.
Regards
In bootstrap_package/Configuration/TypoScript/constants.typoscript you see:
page.fluidtemplate {
# cat=bootstrap package: advanced/100/100; type=string; label=Layout Root Path: Path to layouts
layoutRootPath = EXT:bootstrap_package/Resources/Private/Layouts/Page/
# cat=bootstrap package: advanced/100/110; type=string; label=Partial Root Path: Path to partials
partialRootPath = EXT:bootstrap_package/Resources/Private/Partials/Page/
# cat=bootstrap package: advanced/100/120; type=string; label=Template Root Path: Path to templates
templateRootPath = EXT:bootstrap_package/Resources/Private/Templates/Page/
}
Or:
###############
### FELOGIN ###
###############
styles.content.loginform {
templateFile = EXT:bootstrap_package/Resources/Private/Templates/FrontendLogin/FrontendLogin.html
}
This part tells the templates are loaded from those paths. To override (you say mask i believe) place a copy (which you are going to edit) inside a folder and put in your constants file:
page.fluidtemplate {
layoutRootPath = fileadmin/folder/folder/Layouts
partialRootPath = fileadmin/folder/folder/Partials
templateRootPath = fileadmin/folder/folder/Templates
}
Or:
styles.content.loginform {
templateFile = fileadmin/folder/folder/yourcopyofthefile.html
}
So you can override single templates and entire template folders. Copy the files from an extensions "Resources/Templates" or "Resources/Partials" etc.
Constants can be edited with a constants file set in the backend at Your Root Template (default root template) > Edit > General > Constants field and use :
<INCLUDE_TYPOSCRIPT: source="FILE:fileadmin/folder/folder/typoscript/constants.ts">
Or directly in that field use the code for your override.
Hopefully it helps you further.

typeNum to load content without headers. Does not work in other languages then default

I have this typoscript to request content only (without the header, css, js, etc)
ajaxCall = PAGE
ajaxCall {
typeNum = 999
config.disableAllHeaderCode = 1
config.disablePrefixComment = true
# config.additionalHeaders = Content-type: text/html; charset=utf-8
config.metaCharset = UTF-8
10 = COA
10 < styles.content.get
10.stdWrap.prepend > # supress feEditAdvanced-firstWrapper - Bug in typo3 4.3.1
}
This works fine as long as I am in the default language. But when I want to use this pageType on another language &L=1 it does not work and I get nothing.
I tested around a bit and found out that the problem is here
10 = COA
10 < styles.content.get
It looks like when there is a language parameter the styles.content.get is empty.
Edit: I try to get the content with my own CONTENT object
ajaxCallw = PAGE
ajaxCallw {
typeNum = 1000
config.disableAllHeaderCode = 1
config.disablePrefixComment = true
# config.additionalHeaders = Content-type: text/html; charset=utf-8
config.metaCharset = UTF-8
10 = CONTENT
10 {
table = tt_content
select.orderBy = sorting
select.where = colPos=0
select.languageField = 4
}
}
It looks like select.languageField = 4 gets completly ignored, as it still displays me the content from the default langauge. And when I call a URL with &type=1000&L=4 it still does not show me anything. (Without the L=4 parameter it shows me the default language content)
select.languageField is a pointer to the field in the database
select.languageField = sys_language_uid
As far as I remember the language variable is not parsed by default, so you have to set it yourself
ajaxCall {
# your code
config.sys_language_uid = 0
}
# condition for the language. Adjust it to your language id
[globalVar = GP:L = 1]
ajaxCall.config.sys_language_uid = 1
[global]
The sys_language_overlay = hideNonTranslated was the problem.
Adding: ajaxCall.config.sys_language_overlay = 0 solved the problem.
ajaxCall = PAGE
ajaxCall {
typeNum = 999
config.disableAllHeaderCode = 1
config.disablePrefixComment = true
# config.additionalHeaders = Content-type: text/html; charset=utf-8
config.metaCharset = UTF-8
config.sys_language_overlay = 0
10 = COA
10 < styles.content.get
10.stdWrap.prepend > # supress feEditAdvanced-firstWrapper - Bug in typo3 4.3.1
}
I am not sure why exactly this works now..
styles.content.get is just a CONTENT object that gets the content of col0 (rendered true or with css_styled_content) you can better just fetch your content with your own CONTENT object, thus you can have more control of it.

Typo3 Default language label and flag

I'm working with Typo3 v6.1 and trying to set up multi-language site. The problem is that I can not change the default language label. What am I doing wrong?
According to this and this, here is my TypoScript config
###################################################
# language handling
###################################################
mod.SHARED {
defaultLanguageFlag = de
defaultLanguageLabel = Deutsch
}
config {
sys_language_uid = 0
language = de
locale_all = de_DE.UTF-8
htmlTag_langKey = de_DE
}
[globalVar = GP:L = 1]
config {
sys_language_uid = 1
language = en
locale_all = en_GB.UTF-8
htmlTag_langKey = en_GB
}
[end]
So language settings work and I can localize pages, but default language (uid = 0) is still displayed as Default and not Deutsch. I thought that maybe I'm using old settings and I tried debugging through Typo3 core, looks like these settings still in use in several places, here is one of them:
#/typo3/sysext/backend/Classes/Configuration/TranslationConfigurationProvider.php
$languageIconTitles[0] = array(
'uid' => 0,
'title' => strlen($modSharedTSconfig['properties']['defaultLanguageLabel']) ? $modSharedTSconfig['properties']['defaultLanguageLabel'] . ' (' . $GLOBALS['LANG']->sl('LLL:EXT:lang/locallang_mod_web_list.xlf:defaultLanguage') . ')' : $GLOBALS['LANG']->sl('LLL:EXT:lang/locallang_mod_web_list.xlf:defaultLanguage'),
'ISOcode' => 'DEF',
'flagIcon' => strlen($modSharedTSconfig['properties']['defaultLanguageFlag']) ? 'flags-' . $modSharedTSconfig['properties']['defaultLanguageFlag'] : 'empty-empty'
);
The problem is that Typo3 seems skipping load of my setting (though I do see them in Object browser).
After that I tried also on older version of Typo3 - 4.7.12 and it didn't work out too (((
UPDATE: According to biesior's answer I need to add that code to PageTS config. That works for both Typo3 versions (4.* and 6.*) but also important to know this concepts. And there is a possibility to change the default (i.e. global) PageTS config on behalf of extension:
# /ext_localconf.php of your typo3 v6.* extension:
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig(
'mod.SHARED {
defaultLanguageFlag = de.gif
defaultLanguageLabel = Deutsch
}'
);
or
# /ext_localconf.php of your typo3 v4.* extension:
t3lib_extMgm::addPageTSConfig(
...
);
This code need to be placed in PageTS (of the root page) not in the TypoScript template
mod.SHARED {
defaultLanguageFlag = de
defaultLanguageLabel = Deutsch
}
Just edit properties of the root page, go to the Resources tab, and paste it to Page TSConfig field. Don't forget to clear configuration cache after saving.
You should put the mod.shared stuff in page ts (edit root page properties) not setup ts.
/Brian