Project

General

Profile

Feature #93334

Updated by Benni Mack almost 4 years ago

The syntax for "LLL:" has several drawbacks 

 * It references a path (also uses EXT:) which makes it hard to override 
 * Changing label files is more error prone 
 * The paths are unnecessary longer (EXT:my_ext/Resources/Private/Language/locallang_.xlf) and it is confusing for newcomers to understand both the folder structure and the naming (what does "locallang" mean? or "LLL"?). 

 For this reason, I propose a more "speakable" approach, since we talk about "labels" in this case (not to be confused with "translations" in content). 

 h3. What I want to address 
 * Making the syntax more consistent - find better solutions for "LLL:" 
 * Decouple the label identifier from the file name when addressing the label (making transitions from label names easier) 
 * Decouple the label identifier from an extension name + path 
 * Shorten the identifier massively for its usage 
 * Make it easier for people who CREATE such files to address. 

 h2. A new syntax proposal (totally up for discussion) 

 "label://vendor.package.namespace/resource-name/identifier-in-resource" 

 h3. Examples 

 Previously: LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general 
 New: label://typo3.core/form.tabs/general 

 Previously: LLL:EXT:core/Resources/Private/Language/locallang_tca.xlf:pages.tabs.metadata 
 New: label://typo3.core/tca/pages.tabs.metadata 

 For a TER extension: LLL:EXT:news/Resources/Private/Language/locallang.xlf:news.title 
 New: label://georgringer.news/default/news.title 

 For other extensions: LLL:EXT:my_ext/Resources/Private/Language/locallang_modules.xlf:my-module 
 New: label://a-random-namespace/modules/my-module 

 h3. Usages 

 Fluid: 
 <pre> 
 <f:translate identifier="label://a-random-namespace/modules/my-module">Fallback string</f:translate> 
 </pre> 

 TypoScript: 
 <pre> 
 page.10 = TEXT 
 page.10.lang = label://my.site/resource/site-name 
 </pre> 

 PHP: 
 <pre> 
 $langService->label('label://my.site/resource/site-name') 
 </pre> 


 So, under the hood this is what happens: 
 * A "LabelProviderService" contains all available files registered within the system 
 * The existing "languageService" gets extended to translate the new "label://" syntax into the actual resource + identifier 
 * The existing "languageService->label()" is added to make the syntax more understandable, and falls back if no "LLL:" or "label://" syntax is used 
 * For existing extensions, existing labels can be provided automatically by checking for Resources/Private/Language/locallang.xlf and registering with the composer-name syntax automatically, making any registration for language file very easy and consistent via a ServiceProvider during build-time. 

 Manual registration would be possible as well 

 <pre> 
 LabelProvider->registerResource($pathToFile LabelProvider->registerResource($namespace = '...', $namespace = 'my.site', $resourceName = 'default'); 'default', $path); 
 </pre> 

 h2. Backwards-compatibility 

 * We still allow "LLL:" for a LONG time (just like we keep GeneralUtility::makeInstance() until a long time) 

 h2. Still up for discussion 

 * Overriding labels from extensions locally 
 * Dealing with translation server files

Back