+ res = LabelString.search(line)
+ if res != None:
+ string = res.group(1)
+ if not layouttranslations:
+ writeString(out, src, base, lineno, string)
+ continue
+ res = MenuString.search(line)
+ if res != None:
+ string = res.group(1)
+ if not layouttranslations:
+ writeString(out, src, base, lineno, string)
+ continue
+ res = OutlinerName.search(line)
+ if res != None:
+ string = res.group(2)
+ if not layouttranslations:
+ writeString(out, src, base, lineno, string)
+ continue
+ res = Tooltip.search(line)
+ if res != None:
+ string = res.group(1)
+ if not layouttranslations:
+ writeString(out, src, base, lineno, string)
+ continue
+ res = GuiName.search(line)
+ if res != None:
+ string = res.group(1)
+ if layouttranslations:
+ # gui name must only be added for floats
+ if readingFloat:
+ floatname = string
+ else:
+ writeString(out, src, base, lineno, string)
+ continue
+ res = CategoryName.search(line)
+ if res != None:
+ string = res.group(1)
+ if not layouttranslations:
+ writeString(out, src, base, lineno, string)
+ continue
+ res = ListName.search(line)
+ if res != None:
+ string = res.group(1)
+ if layouttranslations:
+ listname = string.strip('"')
+ else:
+ writeString(out, src, base, lineno, string)
+ continue
+ res = InsetLayout.search(line)
+ if res != None:
+ string = res.group(1)
+ string = string.replace('_', ' ')
+ #Flex:xxx is not used in translation
+ #if not layouttranslations:
+ # writeString(out, src, base, lineno, string)
+ m = FlexCheck.search(string)
+ if m:
+ if not layouttranslations:
+ writeString(out, src, base, lineno, m.group(1))
+ m = CaptionCheck.search(string)
+ if m:
+ if not layouttranslations:
+ writeString(out, src, base, lineno, m.group(1))
+ continue
+ res = Category.search(line)
+ if res != None:
+ string = res.group(1)
+ if not layouttranslations:
+ writeString(out, src, base, lineno, string)
+ continue
+ res = CounterFormat.search(line)
+ if res != None:
+ string = res.group(1)
+ if not layouttranslations:
+ writeString(out, src, base, lineno, string)
+ continue
+ res = Float.search(line)
+ if res != None:
+ readingFloat = True
+ continue
+ res = IsPredefined.search(line)
+ if res != None:
+ string = res.group(1).lower()
+ if string == 'true':
+ isPredefined = True
+ else:
+ isPredefined = False
+ continue
+ res = UsesFloatPkg.search(line)
+ if res != None:
+ string = res.group(1).lower()
+ if string == 'true':
+ usesFloatPkg = True
+ else:
+ usesFloatPkg = False
+ continue
+ res = CiteFormat.search(line)
+ if res != None:
+ readingCiteFormats = True
+ continue
+ res = End.search(line)
+ if res != None:
+ # We have four combinations of the flags usesFloatPkg and isPredefined:
+ # usesFloatPkg and isPredefined: might use standard babel translations
+ # usesFloatPkg and not isPredefined: does not use standard babel translations
+ # not usesFloatPkg and isPredefined: uses standard babel translations
+ # not usesFloatPkg and not isPredefined: not supported by LyX
+ # The third combination is even true for MarginFigure, MarginTable (both from
+ # tufte-book.layout) and Planotable, Plate (both from aguplus.inc).
+ if layouttranslations and readingFloat and usesFloatPkg:
+ if floatname != '':
+ keyset.add(floatname)
+ if listname != '':
+ keyset.add(listname)
+ isPredefined = False
+ usesFloatPkg = True
+ listname = ''
+ floatname = ''
+ readingCiteFormats = False
+ readingFloat = False
+ continue
+ if readingCiteFormats:
+ res = KeyVal.search(line)
+ if res != None:
+ val = res.group(1)
+ if not layouttranslations:
+ writeString(out, src, base, lineno, val)
+
+ if layouttranslations:
+ # Extract translations of layout files
+ import polib
+
+ # Sort languages and key to minimize the diff between different runs
+ # with changed translations
+ languages.sort()
+ keys = []
+ for key in keyset:
+ keys.append(key)
+ keys.sort()