NotAdam / Lumina

A simple, performant and extensible framework for interacting with FFXIV game data
Do What The F*ck You Want To Public License
101 stars 52 forks source link

Broken language request for sub sheets #65

Open Infiziert90 opened 1 year ago

Infiziert90 commented 1 year ago

Requesting a sheet in a specific language will result in the sub sheets not following this request.

Example: TerritoryType requested as german, sheet is german TerritoryType.PlaceName sheet is english

Critical-Impact commented 1 year ago

I'm not sure there's a great solution to fix this. The issue appears to be a side effect of having sheets with no localisation cached(which is a smart thing to do regardless of the side effect). When you load in TerritoryType the first time it's RequestedLanguage is set to whatever language gets requested first(probably English). As it has no localisation, it gets put into the cache using a no language ID. Lumina will always return the no language ID version of a sheet if it's available in the cache. This means that if you request TerritoryType again it'll be the one from the cache with English as it's RequestedLanguage.

The best work around I can think of is overriding the sheets you need in other languages and doing something like this

public LazyRow< PlaceName > PlaceNameGerman { get; set; }
public override void PopulateData( RowParser parser, GameData gameData, Language language )
{
      base.PopulateData( parser, gameData, language );
      PlaceNameGerman = new LazyRow< PlaceName >( gameData, PlaceName.Row, language );
}
NotAdam commented 1 year ago

yeah, this one is a little annoying (hence why it's not fixed yet) but an idea I was playing with but don't really like much is passing through a ThreadLocal<Language> and picking that up in the LazyRow<T> resolver which is a bit less smelly but still sucks very hard lol