我需要使用基于Symfony的Sylius基于subdomain设置语言环境。
我已经完成了以下工作,但我们需要将子域中的区域设置代码映射到本地代码(“ jp.portal.com” =>区域设置“ ja”)
DECLARE
@NOofColumns INT = 5,
@NoOfRows INT = 5
DECLARE
@ColumnNames VARCHAR(MAX) ,
@Initial VARCHAR(16)= 'TAB-',
@SQL VARCHAR(MAX) = ''
;WITH Nums
AS
(
SELECT
1 AS Number
UNION ALL
SELECT
Number + 1
FROM
Nums
WHERE
Number < 99
)
SELECT * INTO #Number FROM Nums
SELECT TOP(@NOofColumns) * INTO #ColumnNumber FROM #Number
SELECT TOP(@NoOfRows) * INTO #RowNumbers FROM #Number
SELECT
ISNULL('['+@Initial + 'R'+XX.ColumnNo+'C'+XX.RowNo+']','') AS Name,
ColumnNo,
RowNo
INTO
#Final
FROM
(
SELECT
CAST(AA.Number AS VARCHAR(8)) AS ColumnNo,
CAST(BB.Number AS VARCHAR(8)) AS RowNo
FROM
#ColumnNumber AA
CROSS JOIN
#RowNumbers BB
)XX
SELECT
@ColumnNames = ISNULL(@ColumnNames+',' ,'') + '['+CAST(AA.Number AS VARCHAR(16))+']'
FROM
#RowNumbers AA
ORDER BY
AA.Number
SELECT
@SQL = @SQL + '
SELECT
'+@ColumnNames+'
FROM
(
SELECT
*
FROM
#Final AA
)XX
PIVOT
(
MAX(NAME) FOR ROWNO in ('+@ColumnNames+')
)yy'
EXEC(@SQL)
DROP TABLE #Number
DROP TABLE #ColumnNumber
DROP TABLE #RowNumbers
DROP TABLE #Final
我遇到的困难将非本地语言代码(例如“ jp”)映射为“ ja”
我尝试使用以下语言环境Listiner,但这无济于事 我遇到错误
#Routing YML
portal:
resource : "../../src/proj/Resources/config/routing.yml"
host: "{_locale}.%site_host%"
prefix: /
requirements:
_locale: 'en|jp'
defaults:
_locale: 'en'
在通过网站生成url路径时出现错误
if (strpos($host, 'jp') !== false) {
$locale = 'ja';
} else {
$locale = 'en';
}
$request->setLocale($locale);
if (null !== $this->router) {
$this->router->getContext()->setParameter('_locale', $request->getLocale());
}