Disable tabs in google spreadsheet exports

More
1 year 3 months ago #3365 by GFX47
Hey, is it possible to store all the terms in a single tab of a google spreadsheet?
I'm croud-sourcing the localization of my game and share the exported google spreadsheet with players, giving them write rights on the language (column) they are willing to help translate. Right now I have to do it for each category/tab, which is very time consuming and prone to errors.

Please Log in or Create an account to join the conversation.

More
1 year 3 months ago #3378 by Frank
Hi,
As you mentioned, I2 Localization exports each base Category into a separate Tab in the Google Spreadsheet.
There is no code to handle merging all into a single sheet, but that can be done by modifying the function

Export_Google_CreateData()
in line 37 of the file Assets\I2\Localization\Scripts\LanguageSource\LanguageSourceData_Export_Google.cs

I haven't tested this (as I'm not in my computer at the moment, but it should work by adding the two lines I marked
		string Export_Google_CreateData()
		{
			List<string> Categories = GetCategories(true);
			StringBuilder Builder = new StringBuilder();

			bool bFirst = true;
			foreach (string category in Categories)
			{
				if (bFirst)
					bFirst = false;
				else
					Builder.Append("<I2Loc>");

				#if !UNITY_EDITOR
				bool Spreadsheet_SpecializationAsRows = true;
				#endif


				category = ""; //<- Add this line so that it exports all terms (instead of just the default category)


				string CSV = Export_I2CSV(category, specializationsAsRows:Spreadsheet_SpecializationAsRows);
				Builder.Append(category);
				Builder.Append("<I2Loc>");
				Builder.Append(CSV);


				break;   //<--- add this line so that it only exports the Default category

			}
			return Builder.ToString();
		}

If it doesn't work, let me know and as soon as I get back to my computer I will do a test and update this code.
Hope that helps,
Frank

Are you :-) Give I2L 5 stars!
Are you :-( Please lets us know how to improve it!
To get the betas as soon as they are ready, check this out

Please Log in or Create an account to join the conversation.

More
2 weeks 2 days ago #4081 by Racines
Hello, I tried your code, this is not changing the result of exporting to google spreadsheet. So I also modified a bit the code on google side in I2GoogleWebServiceV5.

If you want to make this to work you need to make change in LanguageSourceData_Export_Google.cs as Frank post said and also change on google side in I2GoogleWebServiceV5 the file importCSV.gs:
  var lines = CSVstring.split("<I2Loc>");
  var first = true;
  var upMd = updateMode;
  for (var i=0; i<lines.length; i+=2)
  {
     CSVtoSheet(lines[i], lines[i+1], spreadsheet, upMd);
     if (first)
     {
       first = false;
       upMd = "Ignore"
     }
  }
  
  
  if (updateMode=="Replace")
  {
    // Remove non existent categories
    var sheets = spreadsheet.getSheets();
    for (var i=sheets.length-1; i>=0; --i)
      if (!ContainsCSV(lines, sheets[i].getName()) && sheets[i].getName() !== "Main")
        spreadsheet.deleteSheet(sheets[i]);
  }
  
  
  return true;
}

function ContainsCSV( lines, category )
{
  for (var i=0; i<lines.length; i+=2)
    if (lines[i]==category)
      return true;
  return false;
}

function CSVtoSheet(sheetname, CSVstring, spreadsheet, updateMode) 
{
  
  var sheet = spreadsheet.getSheetByName("Main");
  if (sheet===null)
    sheet = spreadsheet.insertSheet("Main");
    

  var csv = ParseI2CSV(CSVstring);
  
  if (updateMode=="Replace")
  {
    sheet.clear();
  }
  else if (updateMode=="Ignore")
  {
  }
  else
    RemoveOldHeaders(sheet);
  
  var range = sheet.getDataRange();
  var rangeData = range.getValues();
  var notes = range.getNotes();

Also to be able to reimport in Unity you need to change the file ExportCSV.gs:
just change this line:
results+="[i2category]"+sheetName+"[/i2category]";
by this one:
results+="[i2category]"+""+"[/i2category]";

Please Log in or Create an account to join the conversation.

Time to create page: 0.996 seconds
Template by JoomlaShine